aspose file tools*
The moose likes Beginning Java and the fly likes I don't know how to use try/catch Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "I don Watch "I don New topic
Author

I don't know how to use try/catch

André Asantos
Ranch Hand

Joined: Nov 23, 2009
Posts: 234
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

Joined: Jan 28, 2008
Posts: 5575

here, there is no reason to use try/catch . what is the use of catching a NullPointerException ?

André Asantos
Ranch Hand

Joined: Nov 23, 2009
Posts: 234
Hmmm

but how could I treat that situation please?


bye,
André AS
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19693
    
  20

Use == null and/or != null to make sure none of the variables is null.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14150
    
  18

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.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I don't know how to use try/catch