Wednesday, 28 March 2018

Encapsulation in java







package javaapplication23;



class employee

{

private int emp_id ;

private String emp_name ;



public void setid(int value)

{

    emp_id=value;

}

public int getid()

{

 return emp_id; 

}





public void setname(String value)

{

    emp_name=value;

}

public String getname()

{

 return emp_name; 

}









}







public class JavaApplication23 {



   

    public static void main(String[] args)   

    {

        employee e=new employee();

       e.setid(1);

       e.setname("ali");

     

        System.out.println("EMPLOYEE ID "+e.getid());

        System.out.println("EMPLOYEE Name "+e.getname());

       

       

     

     

    }

   

}



No comments:

Post a Comment

Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC

Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...