freelanceprogrammers.org Forum Index » Java

Exception Handling help, please!!!


View user's profile Post To page top
mlmatador Posted: Fri Feb 15, 2002 10:11 am


Joined: 15 Feb 2002

Posts: 3
Exception Handling help, please!!!
I am in the process of tokenizing a string in
Java and I keep getting an exception error at the end
of my output that says "exception in thread main".
How can I troubleshoot this to find out what`s
wrong???
Reply with quote
Send private message
View user's profile Post To page top
diahron Posted: Fri Feb 15, 2002 11:59 am


Joined: 15 Feb 2002

Posts: 11
Exception Handling help, please!!!
You need to give more information concerning the
error message. A tidbit more of the code may help. You
may need to go back and thoroughly check your syntax,
it can get confusing after looking at it for a
while. Back off momentarily and then review it, that may
help.
Reply with quote
Send private message
View user's profile Post To page top
brahmbhattalkesh Posted: Fri Feb 15, 2002 4:50 pm


Joined: 15 Feb 2002

Posts: 3
Exception Handling help, please!!!
you have just write "Exception in thread main"
that means in you main method some un-expected error
occure, might is can be ArrayIndexOutOfBoundException or
any other .. but for that i need the whole exception
message.. you have to look for [line no].. and name of
exception as i give example of ArrayIndexOutOfBound... that
means there is some error where size of array is not
proper...<br>Alkesh
Reply with quote
Send private message
View user's profile Post To page top
kingshuk_c Posted: Fri Feb 15, 2002 5:27 pm


Joined: 10 Feb 2002

Posts: 15
Exception Handling help, please!!!
here`s an eg which handles exceptions<br><br>/*
String to be Parsed */<br>String s="I LOVE YOU #CAROL"
;<br>String token;<br><br>if(s!=null) {<br> StringTokenizer
st=new StringTokenizer(s,"#");<br><br> // Loop as long
as long as there are tokens <br> // Otherwise there
will be an exception <br> // NoSuchElementException if
no tokens exist<br> // using the following code u
can avoid that<br> while(st.hasMoreElements()) {<br>
token = st.nextElement();<br> <br> }<br>
System.ou.println("I Love :"+token);<br><br><br>}<br>else<br>
System.out.println("This String Cannot be Parsed as value is null");
Reply with quote
Send private message
View user's profile Post To page top
spooge21 Posted: Fri Feb 15, 2002 7:46 pm


Joined: 14 Feb 2002

Posts: 50
Exception Handling help, please!!!
Try this:<br><br>public static void main(String[]
args){<br>  try{<br>    // your code here<br>  } catch(Exception
e){<br>    e.printStackTrace();<br>  }<br>}<br><br>That way any exceptions which
make it out to the
main() method will be caught and a stack trace will be
produced.<br><br>Sincerely,<br>Anthony Eden
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help