• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Print table code.... shuts down application

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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();
}
}
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic