Results 1 to 5 of 5

Thread: What are an Immutable Objects in Java?

  1. #1
    Join Date
    Jul 2006
    Posts
    218

    What are an Immutable Objects in Java?

    Hi friends,
    I have recently started with the threads of Java programming. Before doing Java, I did C++ and HTML programming language. But I never heard about the immutable objects. Hoping that guys over there would help me on this topic. Please tell me what are an Immutable Objects in Java? And also please tell me how to define an Immutable Objects.!! Help me as soon as possible.!!
    ~*~Silent~Kid~*~
    "To The World You May Be Just One Person, But To One Person You May Be The World"

  2. #2
    Join Date
    Aug 2006
    Posts
    235

    Re: What are an Immutable Objects in Java?

    The following rules define a simple strategy for creating immutable objects. Not all classes documented as "immutable" follow these rules. An immutable object is an object whose state cannot be modified after it is created. An object can be either entirely immutable or some attributes in the object may be declared immutable. Such strategies require sophisticated analysis and are not for beginners. It will be better for you to not have a look on this rules. Because you will not understand anything of that.
    3.2 (northwood)
    2gig ram
    ATI AIW X800xt 256mb
    Gigabyte GA-8knxp 875p Chipset
    Optiwrite 8X DVD Burner
    Win XP PRO Sp2 (Works Perfectly)
    2 SATA Raptor 74gig Raid 0
    2 7200 IDE 320gig HD

  3. #3
    Join Date
    Aug 2006
    Posts
    227

    Re: What are an Immutable Objects in Java?

    In object-oriented and functional programming, an immutable object is an object whose state cannot be modified after it is created. Since you have done C++, I would like to add that its similar using the const member data attribute in the C++ programming language. In some cases, an object is considered immutable even if some internally used attributes change but the object's state appears to be unchanging from an external point of view. An object is considered immutable if its state cannot change after it is constructed.
    I do to dead flowers what people at morgues do to dead people. Suck all the moisture out, dip them in plastic, paint them up pretty and put them in a nice frame.

  4. #4
    Join Date
    Jul 2006
    Posts
    442

    Re: What are an Immutable Objects in Java?

    Maximum reliance on immutable objects is widely accepted as a sound strategy for creating simple, reliable code. Immutable objects are particularly useful in concurrent applications. Since they cannot change state, they cannot be corrupted by thread interference or observed in an inconsistent state. All Java variables are by default mutable. You can make them immutable by using the final keyword. You can also make them private and provide no accessors to the outside world to change them. Programmers are often reluctant to employ immutable objects, because they worry about the cost of creating a new object as opposed to updating an object in place.
    "When they give you ruled paper, write the other way..." J.R.J.

  5. #5
    Join Date
    Jul 2006
    Posts
    286

    Re: What are an Immutable Objects in Java?

    Mutable objects are objects whose state can change. Immutable objects are objects whose state never changes after creation. Immutable objects have many desirable properties. You can share immutable objects between threads without danger of changes confusing the other thread. Immutable objects are thread-safe. Threads cannot corrupt what they cannot change. Immutable objects make good hash keys, since their hash codes cannot change. Two threads can both work on an immutable object at the same time without any possibility of conflict.
    IF you hate me, please don't mention it. I know who hates me and who doesn't. You really do not have to make fun of people....

Similar Threads

  1. Advanced Cache Objects in Java
    By StudyBoy in forum Tips & Tweaks
    Replies: 3
    Last Post: 31-07-2010, 03:41 PM
  2. Return value of generic objects in java
    By Amy Adams in forum Software Development
    Replies: 4
    Last Post: 30-03-2010, 11:42 AM
  3. Array of objects in java
    By Ash maker in forum Software Development
    Replies: 5
    Last Post: 27-02-2010, 02:05 AM
  4. What is mutable and immutable Strings
    By Bottlenecked in forum Software Development
    Replies: 5
    Last Post: 03-02-2010, 01:05 PM
  5. Access to Objects In A JavaBean From Another Java Bean
    By ramsun in forum Software Development
    Replies: 5
    Last Post: 30-01-2010, 01:18 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,678,834.20686 seconds with 17 queries