• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

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
 
CAUTION! Do not touch the blades on your neck propeller while they are active. Tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic