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! While you're at it, check out some resources Treehouse students have shared here.
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 trialayub ali
Courses Plus Student 723 Pointsi need someone to clarify for me four things
what is instance variable; class instance; what is class variables;
2 Answers
Zac Mazza
5,867 PointsAn 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
Jennifer Nordell
Treehouse TeacherHi there, Zac! I also changed this comment to an answer.
Zac Mazza
5,867 PointsYou are my hero! Saving the night tonight. :-)
Thanks again!
ayub ali
Courses Plus Student 723 Pointsayub ali
Courses Plus Student 723 Pointsalright 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