Core Java Tutorial

Core Java Tutorial

What is object in Java

Objects:

Objects or we called it as an instance that are created based on class and holds the copy of member variable and methods. In the following figure e1, e2, e3 are called as Objects,
Syntax for creating Object : Employee e1=new Employee();
Example

public class Main {
 public static void main(String[] args) {
  Employee e1 = new Employee();
  e1.name = "raja";
  e1.age = 20;
  e1.ph = 632736 l;
  e1.email = z @g.com
  System.out.println(e1.name);
  System.out.println(e1.age);
  System.out.println(e1.ph);
  System.out.println(e1.email);

 }
}
Save this file as Main.java along with Employee.java. Now compile and run Employee.java.