Variables [5] 3rd activity


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


Surely it says a bit more than that?

This is what I get when I compile your code:

$ javac error: illegal start of expression
		char movieRating; = 'A';
1 error


Remove the semi colon after movierating


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


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.