Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Exception Handling

  Asked By: James    Date: Jun 09    Category: Java    Views: 756
  

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

Share: 

 

5 Answers Found

 
Answer #1    Answered By: Umaiza Hashmi     Answered On: Jun 09

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.

 
Answer #2    Answered By: Barachias Levi     Answered On: Jun 09

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...

 
Answer #3    Answered By: Naomi Lee     Answered On: Jun 09

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");

 
Answer #4    Answered By: Bathilda Schmidt     Answered On: Jun 09

How can I read and writethe values from XML file by jsp or java beans file?

 
Answer #5    Answered By: Adel Fischer     Answered On: Jun 09

Try this:public static void main(String[]
args){ try{ // your code here } catch(Exception
e){ e.printStackTrace(); }}That way any exceptions which
make it out to the
main() method will be caught and a stack trace will be
produced.

 
Didn't find what you were looking for? Find more on Exception Handling Or get search suggestion and latest updates.




Tagged: