This is one of the most popular String Interview questions in Java , which starts with discussion of, What is String, How String in Java is different than String in C and C++, and then shifted towards what is immutable object in Java , what are the benefits of immutable object , why do you use it and which scenarios do you use it. This is some time also asked as "Why String is final in Java" . Though there could be many possible answer for this question, and only designer of String class can answer this , I think below two does make sense 1) Imagine StringPool facility without making string immutable , its not possible at all because in case of string pool one string object/literal e.g. Why String is immutable in Java
Oracle Oracle Technology Network Java Code Conventions for the Java TM Programming Language Revised April 20, 1999 1 Introduction
Why use inner classes in java So what are inner classes good for anyway? By Tony Sintes, JavaWorld.com, 07/27/01 So what are inner classes good for anyway? Believe it or not, there are advantages to Java's inner classes. But before we go into that, I'll provide a short background on inner classes.
Java class file is a file (with the .class filename extension ) containing a Java bytecode which can be executed on the Java Virtual Machine (JVM) . Java class file is produced by Java compiler from Java programming language source files ( .java files) containing Java classes . If a source file has more than one class, each class is compiled into a separate class file. JVMs are available for many platforms , and the class file compiled in one platform will execute in a JVM of another platform. Java class file