• Post Reply Bookmark Topic Watch Topic
  • New Topic

Diferent behaviour  RSS feed

 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i add this 'break' so that my app works ok, but that's not what i want
When user enters other then '+' or '-', a NPException is thrown. I'd like to know how i can handle that in a way that, when user enters any other string, the app re enters the loop at the beguining of my showing code:
try {System.out.println(p1 + escolhido.getOperacao() + p2 + " ?");}catch (NullPointerException npe) {break;}
I tried several combinations of code but they just dont work;
i also used try/catch in the method that's called, but with no results.
Can someone helpme please?
thanks
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
best make sure the statement is never executed if your "escolhido" is null.
Something like
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in first place thanks for helping!
i keep getting this output from my new code:

i had this same msg before...
hmm, i guess its better post the whole intervening code:
class that has main():

class where csalled method() is in:

[ March 05, 2004: Message edited by: miguel lisboa ]
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!