Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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;


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!



Zac Mazza
Zac Mazza
5,867 Points

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

Thanks again!