Classes


#1

https://www.codecademy.com/courses/learn-java/lessons/object-oriented-programming/exercises/classes-constructor-parameters?action=lesson_resume

I’m not particularly stuck on this exercise. However, I do not understand Classes at all. Like whats the use of it, why is it written in such a way and so on. Right now, I’m just doing the exercise by copying, i honestly don’t understand what its trying to teach.

```

class Dog {

int age;

public Dog(int dogsAge) {

age = dogsAge;
}

}

<do not remove the three backticks above>

#2

each programming language has its own syntax. There isn’t much to understand much about syntax, you have to learn it

Java is very object orientated focussed, maybe not the right language to start with then?

You can always find other sources to read about objects:

https://www.tutorialspoint.com/java/java_object_classes.htm


#3

Hmmm, okay. I’ll look it up. Thanks


#4

Classes are mostly used as blueprints for objects
(sometimes they’re just used to group things together, without creating any instances)

So if you wanted to have car objects you’d have a class with fields for engine, wheels, brand, etc and you’d also have methods which implement the behaviour like driving or handling the locks


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.