Java Basic Programming Elements
- Package:
Packages are group of classes which is used to avoid naming conflicts of same class name. Inside package we need to write our classes.
It is a java folder used to group classes, interfaces and enums.
Ex: package com.software;
public class FirstProgram {
public static void main(String[] args) {
int x=10;
int y=20;
//System.out.println(“Adding x and y”);
System.out.println(x+y);
}
}
2) Class:
3) Interface: All these three are java files used to group java data and logic. 4) Enum:
5) Variable: It’s a named memory location used to store java data.
6) Method: It’s a sub block of a class used to implement logic of an object operations.