Two Laptop Bag*
The moose likes Java in General and the fly likes Print table code....  shuts down application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Print table code....  shuts down application" Watch "Print table code....  shuts down application" New topic
Author

Print table code.... shuts down application

David Shepherd
Ranch Hand

Joined: Mar 02, 2001
Posts: 35
Does anyone see a problem with this code. It seems to occasionally cause my program to just quit. I only use it for testing but I can't find anything wrong.

public static void printTableData(Vector v)
{System.out.println(" --- Table Data ----------------------");
try
{ for(int i =0; i<v.size(); i++)>
{int tempLength =((Vector)v.get(i)).size();
Vector innV =(Vector)v.get(i);
for(int x =0; x<tempLength; x++)>
{
System.out.print(" "+innV.elementAt(x));
}
System.out.print("\n");
}
}
catch(Exception e)
{
System.out.println("table problem");
e.printStackTrace();
}
}
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
If it just quits, then it isn't an exception causing the problem. Try catching Error and printing the trace.
Yeah, I know this isn't normally done because there is normally nothing the program can do to recover from the problem, however just to figure out what is causing the problem might be worthwhile.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Or catch Throwable, which includes both Error and Exception. When you say it "just quits", do you get any error message? If not, you may find it useful to add a bunch of print statements which tell you what part of the program is executing, so the printout actual as a log of the program's activities. This often offers invaluable clues.


"I'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Print table code.... shuts down application
 
Similar Threads
How to write generic method for this method?
How to convert a vector of vectors into a double array?
for(Object name : collection type)
Head First Java - Is over complicated bad?
Snake movement