Solved

Throw exception when a condition is met

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
mapBully challenge 6 89
Eclipse Neon and jdk 1.8.0 11 69
JDeveloper 12c for 32 bit 4 35
Error with Java/Cache JDBC Classpath 2 20
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
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 learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

758 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

19 Experts available now in Live!

Get 1:1 Help Now