Introduction - class in JavaIntroduction to a class in Java Imagine items that can be grouped together like pen, pencil and scissor. The holder acts as a place holder for the items.
The holder is similar to a class in Java which glues related items together. A class consists of fields and methods. Consider the below class file Human.java where there are 5 fields (age,height, weight, sex and smoker). The method isAdult checks if the person is an adult (If the age is more than 17, the person is an adult). Thus fields represent State and methods define Behaviour in a class.
|