Computing.Net > Forums > Programming > Java noob question

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Java noob question

Reply to Message Icon

Name: thermopylae0480
Date: December 17, 2005 at 20:33:26 Pacific
OS: Ubuntu Linux 5.10
CPU/Ram: Celeron D 2.8ghz / 512mb
Comment:

I am new to Java and programming in general, just starting to take a class in the fall. I have two questions. Is there a way to print out a message and make a program stop, like in an if/else statement? example:

if (num1 == 3)
System.out.println ("num1 = 3");
else
{
System.out.println ("num1 != 3");
--command to end program--
}

Also, I programmed in BASIC for about a week and remember a command called GO TO. Is there anything like that in Java?

Thanks in advance.



Sponsored Link
Ads by Google

Response Number 1
Name: Studentin
Date: December 17, 2005 at 21:41:08 Pacific
Reply:

To end the program: System.exit(0);

Nope, there is no GOTO in Java and won't ever be. If you need something like GOTO check about label. Another possibility: just make a new method.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Java noob question

Java Method Question www.computing.net/answers/programming/java-method-question/14684.html

java BufferedReader question www.computing.net/answers/programming/java-bufferedreader-question/10020.html

Java VM question www.computing.net/answers/programming/java-vm-question/11263.html