Ismail qouiqa 28 Jan 2020

Classes' structure

A Class is like a blue print, it describes how the instantiated object will behave in the running program and at what state it will resemble in memory.

Classes structure is mainly composed of two parts, Data and Methods.

Data or state, also known as fields, are stored as part of the object in memory and must have a Data type.
For instance, here is how to declare a variable that will hold an String value
private String variableName="Ismail";
Methods or Functions are a primary component of the OOP paradigm, they operate on data during the life cycle of an application.
For instance, here is a method that initializes the previous integer variable
 public void setVariableName(String variableName){this.variableName=variableName;}

Classes live inside files with the .java extension which are called java files, a Java file can contain an unlimited number of Package private classes, however, it can only contain a single Public class whose name must conform to the name of the java file, otherwise, the java file won't compile.

Package private and Public are java key words known as access modifiers, which we'll see them in detail in a future section.