I'm back at learning Java after a week of brain rest. Just for fun tonight I wrote a simple IF statement using the ! (Not). Which people were kind enough to explain for me last week.
I wrote this code (With out the books help )
When I compiled it in the Termial it spit out an error when it came to the ! part. Long story short when I remove the space between the ! = so it looks like this != the program compiles and runs fine.
In the first chapter in the Java for Dummies it said that java didn;t care about spaces and I could write code one letter or number per line. But when I leave a space between those two it won't compile and errors.
why?
Thanks.
-Lars
I wrote this code (With out the books help )
Code:
import java.util.Scanner;
public class theif
{
static Scanner sc = new Scanner(System.in);
public static void main(String [] agrs)
{
System.out.print("Pick a number ");
int n = sc.nextInt();
if (n ! = 6)
System.out.println("That was not 6");
else
System.out.println("Your number was " + n );
}
}
When I compiled it in the Termial it spit out an error when it came to the ! part. Long story short when I remove the space between the ! = so it looks like this != the program compiles and runs fine.
In the first chapter in the Java for Dummies it said that java didn;t care about spaces and I could write code one letter or number per line. But when I leave a space between those two it won't compile and errors.
why?
Thanks.
-Lars