Results 1 to 4 of 4
Thread: Variables, If, else
- 10-10-2012, 12:14 AM #1
Member
- Join Date
- Oct 2012
- Posts
- 1
- Rep Power
- 0
Variables, If, else
I have experience of Lua, and Ive lately started to learn Java.
I made this simple program to test if- and else-statements in Java, however something here is wrong, and I do not understand the error that output gives me.
import java.io.*;
class Main {
* public static void main (String[] args) throws Exception {
int num = 15;
string str = "Hey";
string str2 = "hey";
if (num == 15)
* * System.out.println("If!");
else
* * System.out.println("Else!");
if (str ~= str2)
* * System.out.println("Strings not equal");
else
* * System.out.println("strings equal!");
* * BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
* }
}
- 10-10-2012, 12:35 AM #2
Member
- Join Date
- Sep 2012
- Posts
- 70
- Rep Power
- 0
Re: Variables, If, else
whats with all the asterisks? its not going to compile with all the **. I would suggest taking them all out except the one in import.java.io.*
-
Re: Variables, If, else
Yes, get rid of the asterisks and instead use [code] [/code] tags around your code blocks posted on the forum.
- 10-10-2012, 01:43 AM #4
Member
- Join Date
- Oct 2012
- Posts
- 31
- Rep Power
- 0
Re: Variables, If, else
Alright I copy and pasted it into my computer to find your errors. and here is what i found(
1. Don,t use asterisks except for the import.
2.when declaring a non primitive like String you must captilize it in the declaration on line 5&6.
3.I assume since you said you used lua that you put ~for dont on line 13. It does not mean that in Java replace it with a !.
4.I dont know if you have some special use or not for it but i ran the program fine in my command prompt without the import,BufferReader,and InputStreamReader.Last edited by Daryn; 10-10-2012 at 01:54 AM. Reason: adding number 4
Similar Threads
-
2 variables get linked
By JavaNoob84 in forum New To JavaReplies: 4Last Post: 11-30-2011, 09:41 AM -
help with variables please
By arimaliz in forum New To JavaReplies: 3Last Post: 03-22-2011, 04:30 PM -
Listening for variables?
By martypapa in forum New To JavaReplies: 6Last Post: 02-09-2010, 09:14 AM -
What are Instance variables and static variables?
By sandeshforu in forum New To JavaReplies: 3Last Post: 09-09-2009, 05:48 PM -
Variables
By mew in forum New To JavaReplies: 3Last Post: 12-11-2007, 12:44 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks