Skip to content

Instantly share code, notes, and snippets.

@anupamhaldkar
Created July 18, 2020 09:47
Show Gist options
  • Save anupamhaldkar/8c633f6953f4eebae1382ec0a5a78df4 to your computer and use it in GitHub Desktop.
Save anupamhaldkar/8c633f6953f4eebae1382ec0a5a78df4 to your computer and use it in GitHub Desktop.
// 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