Java data types are classified as specifiers that assign various sizes and types of values that can be stored in an identifier or variable. There is a rich collection of data types in Java. There are 2 main data types: Primitive and Non-Primitive/Reference.
In the Java language, the building blocks of data manipulation are primitive data types. These are the most basic Java language data types available. Primitive Data Types are predefined in the Java language and are available. It would be difficult to frame programs without primitive data types. Primitive data types are as follows:
A non-primitive type of data is defined as the data type that is derived from primary data types. For the storage of a set of values, non-primitive data types are used. Non Primitive data types are as follows:
class A template that defines the data and actions associated with instances of that class is the basic building block of an object-oriented language. You produce an object when you instantiate a class that looks and feels like other instances of the same class. To build multiple objects, a class can be used. In variables, the data associated with a class or object is stored.
We want to build a library. The library here is an object. To build a library we require a template for the library. We cannot go about directly building the library
This is where class is used. Therefore, to build an object or real-life entity, we will first have a template that determines the contents and behavior of an object. This is called as class in OOP.
Public class Library
//all the methods,
The interface tends to be a class, but it is not a class. Like a class, an interface may have methods and variables, but the methods declared in the interface are abstract by default. Also, by default, the variables declared in an interface are public, static & final. All methods of that interface must be implemented by the class which implements the interface. The Java programming language also does not allow you to extend more than one class, but in your class you can implement more than one interface.
Interface declaration starts with the word interface.
public void a();
public void b();
An array is a container object that contains a fixed number of single-type values. When the array is generated, the length of the array is determined. Its length is fixed after development. An array refers to a structure of data which includes homogeneous elements. This implies that the data form of all the elements in the array is the same. The data items that are positioned in the array are referred to as elements, and the first element in the array begins with index zero. The object class is inherited by arrays. In an array, we can store primitive values or objects.
elementType arrayName[ ];
elementType[ ] arrayName;
int a[ ];
int[ ] a;
A string is a character set, but it is not a primitive form. When we create a Java string, it creates an object of type String. The string is an immutable object, meaning that once it is generated, it can not be modified. The only class where operator overloading is supported in Java is String. There are many methods available which can be used and are discussed in later topics in detail.
String s1 = "abc";
String s2 = "def";