Home > DeveloperSection > Interviews > How to create Immutable class?

Posted on    April-27-2015 12:21 AM

 Java Java  String 
 1 Answer(s)
  398  View(s)
Rate this:

Mayank Tripathi
Mayank Tripathi

Total Post:807

Posted on    April-27-2015 12:21 AM

Create immutable class by creating final class that have final data members

we have created a final class named Employee. It have one final datamember, a parameterized constructor and getter method
public final class Employee{  
final String pancardNumber;  
public Employee(String pancardNumber){  
public String getPancardNumber(){  
return pancardNumber;  

Modified On Apr-27-2015 12:25:29 AM

Don't want to miss updates? Please click the below button!

Follow MindStick