Facebook

adsense

Monday 18 May 2015

QUESTION 17

What is immutable object? Can you write immutable object?
Solution :
Immutable classes are Java classes whose objects can not be modified once created. Any modification in Immutable object result in new object. For example is String is immutable in Java. Mostly Immutable are also final in Java, in order to prevent sub class from overriding methods in Java which can compromise Immutability. You can achieve same functionality by making member as non final but private and not modifying them except in constructor.  

<PREVIOUS || Main Page || NEXT >
        GIVE YOUR COMMENT BELOW

No comments:

Post a Comment