Class:
- It is one of the major concept in OOPS concept
- It act as container to grouping the object
- Without class we can't able to create the object in java program
- Class Name first letter must be capital and should be meaningful
Syntax for Class creation:
public class Home
{
}
public- Access Modifier
class - Keyword
Home- It is the class name
While compile the above program it convert in to .class File but while in execution it throw the error Required public static void main(string [] args) because the program start execute from the main method only and also common method for java program inside of the main method we call many method but in java program main method is most important
public class Home{
public static void main(string[] args)
{
System.out.println("Hello world");
}
}
- Inside Class Have Data members, Method, Objects, Constructor
*Datatypes: *
In Java Data type is divide in to two types
primitive Datatype (Fixed Memory)
Non primitive datatype (Random Memory)
Primitive Datatype:
In this primitive datatype having 8 different datatype to storing the data
Byte:
1 byte = 8 bit => bit represents the binary (2) so 2 power 8 = 256
in that memory allocated -128 to +127 it is used store the small whole number
Short - 2 byte
int - 4 byte
long - 8 byte it is used to store the long whole number we need to add the L at end of the number to indicate the system this number is long datatype
float - 4 byte it is used to store the floating point value by adding the f at end of the number to indicate the system this is the float datatype
Double - 8 byte
char - 2 byte ' ' single quotes is used to store the single character instead of adding the one more character in single quotes it throughs the error.
Boolean - 1 bit (true or false)
Non primitive Datatype:
In non primitive datatype the values or not stored directly in memory instead store reference
Examble :
Object, class, Array, Interfaces, Strings,
Enums: Define a set of named constants.
enum Day {
SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY
}
HashMap , HashSet, ArrayList - collections
Top comments (0)