*
The moose likes Java in General and the fly likes System.out.println not responding ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "System.out.println not responding ?" Watch "System.out.println not responding ?" New topic
Author

System.out.println not responding ?

achana chan
Ranch Hand

Joined: Jul 29, 2002
Posts: 277
Hi.
I've following piece of code which gets inserts a few records into an ArrayList and then try to display them with System.out.println on the Java console. However it is not displaying anything, no runtime errors either.
Maybe some can see some obvious flaw this time:

TIA :-)


humanum errare est.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Your posted code doesn't include a runnable Java program - no main method.
As I see things, the only System.out.println occurs during the course of a for-loop in the init method. The init method is invoked from the insertTXRecord. But I don't see anything calling the insertTXRecord method.
If a main method is inserted, and the insertTXRecord method invoked, then the program throws a ClassCastException since a String that was inserted into an ArrayList is cast to a TXRecord. That's not allowed.
Also, are you sure you want to create two new ArrayLists and discard the old ones each time insertTXRecord is called?


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
achana chan
Ranch Hand

Joined: Jul 29, 2002
Posts: 277
Its no good, Dirk, the moment I mod the code, Java console reports runtime NullPointerException. Even though insertTXRecord() method is called rather than TXRecord().

This is the startup applet that "loads" TXRecord *and* creates the ArrayLists for the first and only time for a given thread :

And this is one of the applet which accesses the insertTXRecord(String, String) in TXRecord:

I'm sure at the end I'd kick myself, but at the moment I can't see the wood for the trees...
TIA :-)
achana chan
Ranch Hand

Joined: Jul 29, 2002
Posts: 277
The above variation of my codes yield this disheartening Java console output

system datetime stamp: Feb 27, 2004 5:19:10 PM
java.lang.NullPointerException
at ConfirmationFrame.TXRecord(ConfirmationFrame.java:341)
...
achana chan
Ranch Hand

Joined: Jul 29, 2002
Posts: 277
If I could any println to work, I'd be much further... :-(
Mathews P Srampikal
Ranch Hand

Joined: Nov 26, 2002
Posts: 211
public void TXRecord() {
// get the static field where pointer to the instance of TXRecord is stored...
txrecord = TXRecord.selfRef;
// now you can call any methods in TXRecord... OK LETS SEE
System.out.println("Brfore");
txrecord.insertTXRecord("yyyyy", "zzzzz");
System.out.println("After");
}

Jus give 2 print stmt berfore and after below statement
txrecord.insertTXRecord("yyyyy", "zzzzz");
Is it printing After???


Thanks,
Mathews
achana chan
Ranch Hand

Joined: Jul 29, 2002
Posts: 277
Hi, Matthew.
Tried your suggestion

And following is the Java console output, so obviously something very bad happened in between...

system datetime stamp: Feb 27, 2004 11:40:00 PM
Before
java.lang.NullPointerException at ConfirmationFrame$prdDtlActionListener.actionPerformed(ConfirmationFrame.java:329)
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923


As far as I can see, acctName is never set/ never assigned a value.
Therefor you get the NPE.


http://home.arcor.de/hirnstrom/bewerbung
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: System.out.println not responding ?