• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I don't know how to use try/catch

 
André Asantos
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please, i would like to know how to configure way to return a message to the user when types a wrong number as 1.5 or when don't exist the number
typed...







metodo main


 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here, there is no reason to use try/catch . what is the use of catching a NullPointerException ?

 
André Asantos
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm

but how could I treat that situation please?


bye,
André AS
 
Rob Spoor
Sheriff
Pie
Posts: 20514
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use == null and/or != null to make sure none of the variables is null.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15219
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some remarks: What exactly is the purpose of your getCliente() method - what should it do and what should it return? Note that as it is written above, the method effectively does nothing at all - it always returns the same Cliente object that you passed into it.

In line 4, why are you creating a new Cliente object? You're not using that object anywhere, and in line 7 you're assigning a different value to variable c, throwing away the Cliente object that you created earlier.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic