Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: James Rivera   on Jun 09 In Java Category.

  
Question Answered By: Naomi Lee   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");

Share: 

 

This Question has 4 more answer(s). View Complete Question Thread

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


Tagged: