This code will keep printing JavaProgrammingForums.com to the console until the myBoolean value is changed to false.

May 13th, 2010, 01:11 AM

javanub:(

Re: (while) insted of (try and catch)

why dun wanna use try catch

May 13th, 2010, 02:38 AM

helloworld922

Re: (while) insted of (try and catch)

well, there is the whole issue of looping. try/catch blocks execute the code inside them only once/call. Also, try/catch blocks are fairly slow (depending on the situation, can take milli-seconds where simple value checking using if/else or other conditionals are maybe an order or two of magnitude faster). If you want a pseudo replacement for try/catch, use if/else statements for the comparisons and handle the code flow as needed.

The only time you really should be using try/catch blocks is when there is a situation that you don't want a method to handle a certain type of situations, usually from bad data passed in.