Variables [5] 3rd activity


#1

public class Variables {
public static void main(String[] args) {

	int myNumber = 42;
	boolean isFun = true;
	char movieRating; = 'A';


}

}

I set it to = 'A'; but it is not working for me said "=" is illegal


#2

Surely it says a bit more than that?

This is what I get when I compile your code:

$ javac Variables.java 
Variables.java:5: error: illegal start of expression
		char movieRating; = 'A';
		                  ^
1 error

#3

Remove the semi colon after movierating


#4

A little bit of an explanation on why and how to troubleshoot would be appreciated by all the learners here.


#5

In java semi colon puts an end to the code. So you basically started a new code with '=' which is invalid way to start a code. Look at it like a math problem the = can't be the first integer to start.