Put doesn't work

Why doesn't this work? :(

It's the object to char that is wrong. If I type buf.put(2); below it works fine...

In class Producer

private CharacterFactory cf;

buf.put((Object)(cf.returnChar()));

In class CharacterFactory

public Object returnChar(){

Object tmp = (Object)(alphabet.get((int)((Math.random())*24)));

return tmp;

}

In class Buffer

publicsynchronizedvoid put(Object obj){

buffer.add(obj);

notify();

}

Exception in thread "Thread-3" java.lang.NullPointerException

at Producer.run(Producer.java:22)

at java.lang.Thread.run(Unknown Source)

Exception in thread "Thread-4" java.lang.NullPointerException

at Producer.run(Producer.java:22)

at java.lang.Thread.run(Unknown Source)

Exception in thread "Thread-5" java.lang.NullPointerException

at Producer.run(Producer.java:22)

at java.lang.Thread.run(Unknown Source)

Message was edited by:

_Robb_

Message was edited by:

_Robb_

[1388 byte] By [bronze-starDukes] at [2007-11-26 12:10:51]
# 1
This question is off-topic for this forum. I recommend that you try oneof the forums in the "Java Essentials" category: http://forum.java.sun.com/category.jspa?categoryID=5
bronzestar at 2007-7-7 14:08:26 > top of Java-index,Archived Forums,Socket Programming...