this is my code :
String name = "Mohan";
String is a immutable class and where these character stored when we assign some character.
How the logics are working inside the String class.
Please advise and thanks for the valuable reply .
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
this is my code :
String name = "Mohan";
String is a immutable class and where these character stored when we assign some character.
How the logics are working inside the String class.
Please advise and thanks for the valuable reply .
I'm not really sure what your question is. What exactly are you confused about? Have you tried googling something like "java immutable"?
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
I got the meaning of immutable but see my code ., where the character are storing in that class., i tried decoder of String class and i am not able to get home the character [Mohan] assigned in that variable ?
--- Update ---
* how [ not home ]
I still don't really know what you're asking.
Are you asking what the internals of the String class look like? If so, consult the source that comes with the JDK.
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
Explain this:
If there is code involved, please post it with your explanation. For example,i tried decoder of String class and i am not able to get home the character [Mohan] assigned in that variable
System.out.println( name );
will print the String "Mohan" to the console (or standard out), but I'm not sure that's what you mean.
Where the actual UTF-8 character bytes are stored by a running VM is implementation specific. Typically, immutable objects are stored in a special part of the memory reserved by the VM for use by all threads, but this is not defined by the language spec. It could just as well be on the heap.
Now, String is a bit special, as it has qualities associated with primitives even though it is a class. This was for convenience.