Java
What is the syntax for Java to use a if - then goto command?
I used to be able to use IF F$ = something then goto something
something: commands
In qbasic. Is there a goto for java or is it all in separate classes?
Login |
JavaJavaCurrently viewing this thread: 1 (0 members and 1 guests) ZwitterionStatus: Offline!
Java What is the syntax for Java to use a if - then goto command? I used to be able to use IF F$ = something then goto something something: commands In qbasic. Is there a goto for java or is it all in separate classes? Do you know what methods are? Unlike BASIC, where you do GOTO LINENUMBER, Java doesn't use line numbers. So you need to write methods for a separate "process". Read on methods if you don't know what they are, and you will like it a little more than the GOTO stuff in BASIC you just need to work with if- / if-else statements..... if( i == 0) //// else LoL yeah I know it isn't state of the art example, but don't know exactly what you need... Not quite familair with BASIC or any other compiled language ZwitterionStatus: Offline!
Would: public int mult2(int p, int q){ be an example of a method? ZwitterionStatus: Offline!
One last question: How do I get a text input from a user and use it as a variable? I tried
But it didn't work. The_One1Status: Offline!
the method you had is right! what you would have to do is have something like: int temp = 0, p = 1, q = 7; temp = mult2(p, q) and it would save what is n in the method in temp, you can also have methods that don't return anything, just replace the int by void! and to read from keyboard you use: var1 = keyboard.readLine(); to save it as int you use: Integer.parseInt(keyboard.readLine()); because java takes all input as a String, and that would convert to integer double.parseDouble(keyboard.readLine()); converts to double! Have FUn! Let me give you something that will eiminate redundant statements for user input. Try the following method:
And what The One said will apply to this as well PS: Just realised the difference in syntax for the "reader". Don't worry about it. I doubt if there's much of a difference. Last edited by kgx, January 17th, 2003 09:44 AM (Edited 1 times) ZwitterionStatus: Offline!
Ok, I got the get user input figured out, but now I have another problem. When I get the text input from a user, I want it to send them to a different class and execute the commands there.
But nothing seems to happen after I type in what "subject" should be. akumaStatus: Offline!
Zwitterion I removed the double post you had, which is probably why TheOne gave the response s/he did. TheOne I also removed the response to the post that I removed of Zwitterion's. In case you were wondering where it went. heh, that's kind of confusing. Last edited by akuma, January 18th, 2003 12:41 AM (Edited 1 times) kixster_2002Status: Offline!
that's because you cannot compare Strings in java using ==
|
Copyright ©1999-2008 Neverside. All rights reserved.
Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach
NeverAPI generated this page in 0.0088 seconds.