Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is immutable class? how to make a Class explicitly
"Immutable"?Wap to make a class explicitly immutable.

Answer Posted / rv.nandakishore

I think u know... String is not a data type.. it is a
class...right..

By default the String class is a immutable class. That means
once we instantiate the object or assigning the value to
String is immutable. Once we can assign / instantiate the
String class we can't change in the future....


class StringDemo
{
public static void main(String[] args)
{
String s1="Nanda";
String s2="Kishore";
String s3=new String("Nanda Kishore");
System.out.println(s1);
System.out.println(s2);
System.out.println(s3);
}
}



U try any changes anything and print s1,s2 & s3.... If
changes then it is not immutable. If not it is immutable.


Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is var keyword ?

1191


What is garbage collection? What is the process that is responsible for doing that in java?

1106


What is an example of a keyword?

1109


Is {a, n, d} a palindrome? If you are given a random string, is it a palindrome or not?

1134


Do I need java on my pc?

1054


What is the difference between yield() and sleep()?

1017


Explain the difference between private, public, package and protected in java?

1045


Explain exception chaining in java?

1177


Why we do exception handling in java and how many types of exceptions are there?

1127


Class c implements interface I containing method m1 and m2 declarations. Class c has provided implementation for method m2. Can I create an object of class c?

1618


What is the difference between normal report & matrix report?

1110


What is gc()?

1070


What are the five major types of reference sources?

1133


Can a static method be overridden in java?

1025


What is a marker interface?

1165