Solved

Throw exception when a condition is met

Posted on 2006-11-07
3
186 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

932 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now