Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to use "throw IllegalArgumentException" in code

 
P Derlyuk
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're very welcome!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic