*1. What is Java Immutable class.?*

An immutable class is one whose object of that class is created, it cannot
be modified


*2. Write a java Immutable class.*

public final class MyOwnImmutableClass{

private final name;

public String getName(){return name;}

}

That is it! To make a class immutable, ensure the class is final, hence
cannot be extended, the fields are final hence cannot be modified and no
setter method should be provided to such class.



*3. Advantages of java Immutable class.*

One major advantage of immutable classes is that they are thread safe.
Could be shared between  multiple threads


*4. Disadvantages of java Immutable class. *

In extreme cases, they could slow down . Read this stack overflow for more
on this ==>
http://stackoverflow.com/questions/752280/downsides-to-immutable-objects-in-java


*5. Any impact of Java Immutable class on Performance ? *

Well, both the advantageous and disadvantageous characteristics impact your
class performance.



*6.If you have any other points on Java Immutable class.please advise.*

My advice, might not worth it, I haven't seen this used in most of my
coding. So, I can't advice you much on it. Perhaps, other more experienced
developers could shed more light on practical application of immutable
classes. I only use the String and wrapper classes in Java for my needs.
Never bothered to write mine in real applications.


On Fri, Jul 3, 2015 at 6:48 PM, Deepak A L <[email protected]> wrote:

> hi pple
> i have below queries
>
> 1. What is Java Immutable class.?
> 2. Write a java Immutable class.
> 3. Advantages of java Immutable class.
> 4. Disadvantages of java Immutable class.
> 5. Any impact of Java Immutable class on Performance ?
> 6.If you have any other points on Java Immutable class.please advise.
>
> Regards,
> Deepak
>
> --
> You received this message because you are subscribed to the Google Groups
> "JPassion.com: Java Programming" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> Visit this group at http://groups.google.com/group/jpassion_java.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"JPassion.com: Java Programming" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at http://groups.google.com/group/jpassion_java.
For more options, visit https://groups.google.com/d/optout.

Reply via email to