7.Objects


#1

I cant seem to get passed this exercise and i have no idea what i am doing wrong can anyone help?


#2

In the first instance, you have a Class declaration without an identifier.
Java interpreters don't understand an undefined Class.


#3

For elaboration:
You have a class with no identifier, then you have a second (redundant) class with the identifier 'Dog'.

class {
   class Dog {
      int age;
...

You can delete the first class entirely and that should solve your problem. The final result should be:

class Dog {
   int age;
...

#4

I don't understand that exercise at all either!

It just addresses about every 'integer, class, instance, object' that after my 1 day Java class, I have no clue about what it actually all means.

It looks very complex.

I just copied the Car example, and put Dog there, and happened to succeed the exercise, but in all honesty, I think it just speaks of my IQ to find solutions, when language is a barrier, and I don't understand 10-20% of the words they say there....


#5

The answer is here for future viewers / OP.

class Dog {

 int age;

 public Dog(int dogsAge){

age = dogsAge;

}

public static void main(String[] args) {

Dog spike = new Dog(2);

}

}

#6

This is my code and it's not letting me pass:

class Dog {

int age;

public Dog(int dogsAge) {
age = dogsAge;

}

public static void main(String[] args) {

Dog Spike = new Dog (2);

}

}


#7

looks like I had Spike instead of spike.... this is really challenging


#8

You should Write 'spike' not 'Spike'.

One more important thing All method,object name should start with a Lower Case Letter.
If several words are used to form a name of the class, each inner word's First letter should be in Upper Case.

e.g:- myFirstObject ;dogsAge;

But for class name first letter should be in Upper Case and the rest is same.


#9

Damn! I did it about 10 times in a row!
But now it works)

Just a magic, nothing personal))


#10

Mine accepted after I hit run twice........


#11

A post was split to a new topic: 7. I'm having trouble with this exercise


#12

Thank you man, I was having trouble with this one!


#13