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 Harnessing the Power of Objects Constants

Reem Javaid
Reem Javaid
920 Points

A few questions AND feedback!

Hi guys,

hope someone can help me:

1) shouldn't it be in this order: final public static int MAX_PEZ = 12; similar to: final private String characterName;

2) What is an INSTANCE Variable? What is an INSTANCE? Is it the Object, in this case, the dispenser?

3) What is %d?

The Java Basics course was a breeze, but now I'm finding it difficult to grasp the material. There are so many terms used in the one video that it makes it difficult for me to keep up with what the instructor is saying. Getting really discouraged at this point! Is it just me? Should I keep going?

Hi mate, I'm in the same boat as you just now. Did you keep at it? I'm struggling with this module myself. Hoping it get's a little easier to absorb.

Julie Austin
Julie Austin
1,322 Points

It's not just you. He's slamming a lot of terms we've never addressed plus he just did a ton of stuff with jshell he's also never shown and often changes formats or techniques like in the first module he used \n for a new line and abruptly switched to %n with no explanation and talked about it like he'd done it all along. I'm having to watch videos 5-10 times now to sort it all out when I was only having to watch 1-2 times before :(

4 Answers

For #3, the %d is just like the %s, where s is for string but d is for whole numbers like int. %f is also used for floats (i.e. doubles)

Awesome , I did wonder how one would know if they were needing to use %s, %d, or %n etc as seen in this course. Is there a name for these ? (So that I can search for a table that will clarify each one etc?) Thank you

An access modifier i.e. "public" or "private" will typically be first.

public static final int MAX_UNITS = 25;

I would go back and review then keep going, or go to another resource and then come back and keep going...or both. But don't give up. Persistence pays off and some ideas just take a bit longer to solidify.

ha, answered my own question! https://en.wikipedia.org/wiki/Printf_format_string useful for anyone else who was curious :)

Think of the "class" as a blueprint for an object, say a house plan in a new suburb. The "instance" is the particular cookie cutter house built on 1st Ave and Main St.

The properties aka fields of the house will be different depending on the house and who buys it. Its location will be different, how many bedrooms, square footage, the potential owner. These are all things we pass into the class when we create a new instance of the class. But what a house is, its main features and what its functions do not change.

The same can be said for a car. All cars for the most part have an engine, four wheels, steering wheel, seats, etc. However, there are certain features that each brand might have different, like color, size, amount of seats, horsepower, brand name, etc. Those would be instances of the car class.

Hope this helps.