Solved

Throw exception when a condition is met

Posted on 2006-11-07
3
193 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn different types of Android Layout and some basics of an Android App.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

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