Created
July 18, 2020 09:47
-
-
Save anupamhaldkar/8c633f6953f4eebae1382ec0a5a78df4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Java Program of JavaBean class | |
public class Employee implements java.io.Serializable | |
{ | |
private int id; | |
private String name; | |
public Employee() | |
{ | |
} | |
public void setId(int id) | |
{ | |
this.id = id; | |
} | |
public int getId() | |
{ | |
return id; | |
} | |
public void setName(String name) | |
{ | |
this.name = name; | |
} | |
public String getName() | |
{ | |
return name; | |
} | |
} | |
// Java program to access JavaBean class | |
public class Test { | |
public static void main(String args[]) | |
{ | |
Employee emp = new Employee(); // object is created | |
emp.setName("AH"); // setting value to the object | |
System.out.println(emp.getName()); //fetching value from the object | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment