Attributes
Lesson 3 of 12 in Coddy's Basics of Classes and Objects in Java course.
Attributes (also known as fields) are the values inside the classes.
class Point {
int x = 0;
int y = 2;
}In the above example, we create a class named Point with two attributes, x and y with the values 0 and 2 accordingly.
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
Challenge
EasyCreate a class named Coder with two attributes:
- A string typed value named
namewith your name - An integer typed value named
agewith your age
Try it yourself
// Write code hereAll lessons in Basics of Classes and Objects in Java
1Introduction
Introduction