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?

Lex Dunko
Lex Dunko
1,573 Points

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.

4 Answers

Jason Thomas
Jason Thomas
11,736 Points

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.

Steve Lewin
Steve Lewin
6,691 Points

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

ha, answered my own question! useful for anyone else who was curious :)

Anthony Albertorio
Anthony Albertorio
21,632 Points

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.