Java Java Basics Perfecting the Prototype Conditional ints

i need someone to clarify for me four things

what is instance variable; class instance; what is class variables;

Conditional.java

alright the curly braces you are talkinga about; is't between open and closed curly braces like this {instance variable} or like this: {instance variable {, clarify please, you said everthing in the two curly braces is the instance variable

2 Answers

Zac Mazza
Zac Mazza
5,867 Points

An instance is defined by the class, method, or conditional statement. Scope is what is between the two curly braces. Class variables are variables defined in the scope, and instance variables are those defined in the class, method, or conditional statement. For example:

public class InstanceExample { //This is a class instance, and everything in this instance is between the curly braces.
    //class variables go here.
    public InstanceExample() {
      // constructor code goes here
   }

    public void printHello() {
        String message = "Hello"; // This is an instance variable, defined within the method.
    }
}

Hope this helps!

Thanks,

Zac

Zac Mazza
Zac Mazza
5,867 Points

You are my hero! Saving the night tonight. :-)

Thanks again!