Hi ,I am trying to catch exception if integer is out of certain interval ,how can I do that.
Lets say that float variable has to be in the interval 2 to 5 in all other cases exception
Thanks

Recommended Answers

All 3 Replies

if statements.

You can test the value (see previous post) and if it's out of range you can throw a new Exception

throw new Exception("value out of range");

<sorry> no, not, never, why catch something what exatctly exists, that's limited with nonsense, why you created any Integer Array, and into others method, viod or class you must ...., that's little bit stupid, isn't it </sorry>

you have to be ensure and to pass your Integer range througth all possible methods, voids and classes, with public static declaration, if you aren't familiar with getter/setter, constructor or Generics etc.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.