Posts

Showing posts from December, 2021

Getters and Setters in java.

class Employee{     private int id;      private String name;          public void setid(int id){         this.id=id;     }     public int getid(){         return id;      }     //Complition of id           public void setname(String name){         this.name=name;              }     public String getname(){         return name;     }     //Completion of name } public class Nilesh{     public static void main(String args[]){     Employee b=new Employee();     b.setid(12);     System.out.println(b.getid());     b.setname("Nilesh");     System.out.println(b.getname());      } }