|
-
Begining to learn Java
Hi Everybody
Am a novice to Java triyng to learn it from scratch. Am referring the Java
How to Program by Deitel & Deitel
I tried one of the examples from the book but it pops up following runtime
error.
Exception in thread "main" java.lang.NoClassDefFoundError:Comparision.class
My code is given below :
import javax.swing.JOptionPane;
public class Comparision {
public static void main ( String args[] )
{
try
{
String firstNumber, secondNumber, result;
int number1, number2;
firstNumber = JOptionPane.showInputDialog("Enter first integer:");
secondNumber = JOptionPane.showInputDialog("Enter second integer:");
number1 = Integer.parseInt(firstNumber);
number2 = Integer.parseInt(secondNumber);
result = "";
if(number1 == number2)
result = result + number1 + " == " + number2;
if(number1 != number2)
result = result + number1 + " != " + number2;
if(number1 < number2)
result = result + "\n" + number1 + " < " + number2;
if(number1 > number2)
result = result + "\n" + number1 + " > " + number2;
if(number1 <= number2)
result = result + "\n" + number1 + " <= " + number2;
if(number1 >= number2)
result = result + "\n" + number1 + " >= " + number2;
JOptionPane.showMessageDialog( null, result, "Comparision Results",
JOptionPane.INFORMATION_MESSAGE);
System.exit( 0 );
}
catch (Error err)
{
System.out.println("Error Trapped");
}
}
}
I cant figure out where to look for the error. Can some body help!!!!!!!!!!!!!!!!!!!!!
Alfy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks