Solved

Throw exception when a condition is met

Posted on 2006-11-07
3
192 Views
Last Modified: 2010-03-31
Hi;
I would like to do the foll
if(totalDiscount > 100) then throw an Exception,when totalDiscount is a variable that holds all the associated discounts.
Thanks in advance
0
Comment
Question by:aswam1975
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 30 total points
ID: 17893153
if(totalDiscount > 100) {
    throw new RuntimeException("Total exceeded");
}
0
 
LVL 92

Expert Comment

by:objects
ID: 17893167
if(totalDiscount > 100) throw new IllegalArgumentException("Total discount cannot exceed 100");
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17893199
:-)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to implement Singleton Design Pattern in Java.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question