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 trial

Java

Java objects?

Hello,

When creating a class are the Member Variables objects? I am not entirely sure about this. See the example below:

public class PezDispenser {
    //Is this bit of code an object?
    public String mCharacterName = "Yoda";
} 

Thanks :)

3 Answers

No. Variables inside of classes are just plain old variables that are part of that class.

For example if I had a dog class it might have three member variables: color, weight, and name.

Ok so you can create an object like this...

PezDispenser dispenser = new PezDispenser();

Exactly :)

Brill, thanks for your help :)

No probs :)

I'm rather new to Java though lol I just have some knowledge with objects (it is a very common concept among the programming languages)