• 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

exception & loop

 
Ranch Hand
Posts: 111
Eclipse IDE Firefox Browser Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
while ((itElements.hasNext()))
{
String sElement = (String) itElements.next();
try
{
String sErrorCode = op2.method_ThrowsEx(sElement);
}
catch(Exception e)
{
e.printStackTrace();
}
}

I Know that iterator has 5 elements,
Frist time I call method_throwsEx(sElemtent) an Exception is thrown , stack is printed and the loop ends.

Why does while ends at the frist element?

Does a loop ends when a exception is thrown?

Thans in advanced
 
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Fernando Dominguez:

Does a loop ends when a exception is thrown?



Nope, the loop should not end if the exception is catched.
What is the stack-trace that is printed? Are you sure it is from the exception you expect? (The code in the catch can also throw an exception)
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are throwables that can stop a while loop even if there is a try catch clause. Do you have the stack trace so we can have the detail?
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jaime Tovar:
There are throwables that can stop a while loop even if there is a try catch clause.


Hmm. Can you give an example?
 
Jaime M. Tovar
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
java.lang.OutOfMemoryError
 
Paper beats rock. Scissors beats tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic