How to make a class immutable?

Answer Posted / ravi jain

in above ans

marking the all methods as final gives no mean as
class is final.

for methods point of view do not provide any
setter/mutator methods in class.

Is This Answer Correct ?    2 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can a class extend 2 classes in java?

531


How to create a base64 decoder in java8?

531


What is tostring () method?

518


What is java basic concept?

503


What is a databasemetadata?

526






What is floating data type?

512


What does the string method compareto () do?

520


What is final keyword?

615


How do you end a program?

522


Define canvas?

538


What is the technique adopted to create an immutable class?

495


What is the length of a string?

494


Can we have any code between try and finally blocks?

532


Write a program to print count of empty strings in java 8?

510


What is an array in java?

617