File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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

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

but how could I treat that situation please?

André AS
Rob Spoor

Joined: Oct 27, 2005
Posts: 20276

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

How To Ask Questions How To Answer Questions
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15092

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 8 API documentation
I agree. Here's the link:
subject: I don't know how to use try/catch
It's not a secret anymore!