It's not a secret anymore!*
The moose likes Beginning Java and the fly likes identify exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "identify exception" Watch "identify exception" New topic
Author

identify exception

Ritesh raushan
Ranch Hand

Joined: Aug 29, 2012
Posts: 100
my problem is that....at the time of developing application we don't pass (anyintnumber/0) then no exception occurs because i didn't think about that but when

i deploy the application my client enter (anyintnumber/0) and exception occurs.....

at the time of developing how will i know that if user enter anyintnumber/o exception occurs...

any mechanism for checking or it's depend on developer to think about that then it's very big burden on programmer.....


Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14276
    
  21

Ritesh raushan wrote:any mechanism for checking or it's depend on developer to think about that then it's very big burden on programmer.....

That's exactly one of the reasons why programming is hard. If you're the developer, you have to think carefully about what happens with any input given to the program.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
nir sharma
Ranch Hand

Joined: Sep 11, 2012
Posts: 72

Well, it depends on you how you plug those loop holes that can cause you application to fail, you cannot expect user to enter only definite set of values when there is not restriction. User intentionally or unintentionally can enter any figure, its up to you how you handle it.
In the example mentioned, you can even match whether its a number or not before parsing it.

Regards
Nir
Nikhil Sagar
Ranch Hand

Joined: Apr 21, 2012
Posts: 216

i deploy the application my client enter (anyintnumber/0) and exception occurs.....

This is why we call them exceptions.
You can expect them at run time but nothing is guaranteed, an exception may or may not occur at run time.


OCPJP 6 86%
 
Consider Paul's rocket mass heater.
 
subject: identify exception