Lesson 1 last part


#1



https://www.codecademy.com/courses/learn-java/lessons/introduction-to-java/exercises/generalizations?action=lesson_resume


Generalizations.java:6: error: ';' expected
boolean isComplete(true);
^
1 error


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

    //comment//

		boolean isComplete(true);
		int awesomeLevel;
		int epicLevel;		
		/*System.out.println(epicLevel);*/
		
    //comment//

    
	}
}


#2

i put a space before (true) not sure what i'm missing. it says set boolean variable isComplete to true... how am i supposed to do that?

Beginner here


#3

isComplete is a variable not a method.

boolean isComplete = true;

#4

I haven't learned the difference between method and variable. If you have time to explain I'm happy to listen and learn


#5

In general, variables are symbols that associate a name (the identifier) with a value. Like in:

boolean isComplete = true;
/**
* Here, boolean is the type of the variable
* isComplete is the name of the variable
* and true is the value of the variable isComplete
**/

However, you can not assign a value to the variable. eg:

int awesomeLevel; // Here, awesomeLevel is a variable and his type is int
int epicLevel; // Here also, epicLevel is a variable and his type is int

In object-oriented programming (OOP), a property or an attribute is just a variable that is inside a class or an object while a method is a function that is also specific to an object or to a class.
Contrary to the attributes, the methods are distinguished by the parentheses (). eg:

boolean isComplete(true);
/**
* Here booleen is the return type of the function/method
* isComplete is the name of the method
* The value (true) between the parentheses is called an "argument"
**/

I invite you to continue the course, you will understand better.


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.