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.

Results 1 to 6 of 6

Thread: Meaning of String or immutable class

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Meaning of String or immutable class

    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 .


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Meaning of String or immutable class

    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!

  3. #3
    Junior Member
    Join Date
    Aug 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Meaning of String or immutable class

    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 ]

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Meaning of String or immutable class

    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!

  5. #5
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Meaning of String or immutable class

    Explain this:
    i tried decoder of String class and i am not able to get home the character [Mohan] assigned in that variable
    If there is code involved, please post it with your explanation. For example,

    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.

  6. #6
    Member jdv's Avatar
    Join Date
    Jul 2014
    Location
    This Land
    Posts
    73
    Thanks
    0
    Thanked 5 Times in 5 Posts

    Default Re: Meaning of String or immutable class

    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.

Similar Threads

  1. How to test if class/object is immutable
    By dhasija in forum What's Wrong With My Code?
    Replies: 8
    Last Post: July 10th, 2014, 01:03 AM
  2. [SOLVED] Immutable String
    By lddangsta in forum Object Oriented Programming
    Replies: 7
    Last Post: February 27th, 2014, 09:52 AM
  3. differnce between String class and Integer class
    By Indrajeet in forum Java Theory & Questions
    Replies: 2
    Last Post: December 16th, 2012, 07:22 AM
  4. immutable
    By chalapathi in forum Java Theory & Questions
    Replies: 2
    Last Post: May 7th, 2012, 09:31 AM
  5. To Make class immutable which has ref to other mutable objects
    By tcstcs in forum Object Oriented Programming
    Replies: 1
    Last Post: May 4th, 2012, 10:42 AM