my dog learned polymorphism*
The moose likes Beginning Java and the fly likes How to use Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to use "throw IllegalArgumentException" in code" Watch "How to use "throw IllegalArgumentException" in code" New topic
Author

How to use "throw IllegalArgumentException" in code

P Derlyuk
Ranch Hand

Joined: Feb 17, 2013
Posts: 33
I don't how to add a throw IllegalArgumentException in my method. This formula (the slope formula) fails for points with identical x-coordinates and i need a throw IllegalArgumentException. I haven't learned about this yet so any help would be great!


Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

For example...



You can be as general or as detailed as you want to be in how you test for conditions (separate tests for each, or just one big AND or OR that's a simple pass/fail) and how much information you provide about what was wrong and why.
P Derlyuk
Ranch Hand

Joined: Feb 17, 2013
Posts: 33
Thanks!
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

You're very welcome!
 
wood burning stoves
 
subject: How to use "throw IllegalArgumentException" in code
 
Similar Threads
How can I get my line shape to stay positioned when moving it?
constructor method help
Need help with Linear Equations.
Can't get my line shape to move when other shapes have been drawn
Dragging Components Relative To Eachother