program
write a program which accepts two numbers as command line arguments and prints the least number of the two. If the input is not a number print "Error" .
how to print error ?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
program
write a program which accepts two numbers as command line arguments and prints the least number of the two. If the input is not a number print "Error" .
how to print error ?
System.out.println( "error" );
System.err.println( "error" );
Even prettier.
what is the condition bro
The input is not a number.
ya if the input is not a number print "Error"
what is the condition for input is a char or something @phHein
You will have to convert the input from String to a number. If the user enters something else, a NumberFormatException or something similar will occur. Read the API docs for the various parse() methods from the wrapper classes, like Integer, Long, etc.
k thanks for the info bro