• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

What is immutable class ?

 
Ranch Hand
Posts: 63
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

this is kiran, please explain me 'what is immutable class ?', & also tell me about the java IDEs.
suggest me a good IDE to learn.

thanks in advance.
 
Ranch Hand
Posts: 231
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Immutable is when something can't be changed after it is created, for example the String class, there is a basic explanation here : http://en.wikipedia.org/wiki/Immutable_object

Regarding IDEs, download Eclipse or Netbeans, they are 2 popular Java IDEs (personally I prefer Netbeans because its a bit simpler IMHO)
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseOneThreadPerQuestion

If you are at a beginner stage, I would strongly recommend against using any type of IDEs. Start off with using a simple text editor like notepad and progressively move towards an IDE .
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Maneesh Godbole wrote:Please UseOneThreadPerQuestion

If you are at a beginner stage, I would strongly recommend against using any type of IDEs. Start off with using a simple text editor like notepad and progressively move towards an IDE .



No offence intended. Why? I would think being able to know spot syntax errors, use auto-complete and, the constant javadocs features would be extremely helpful to programming novice. I'm new to Java, but not programming and OOP, and using the IDE has allowed me to progress at a much greater rate then a plain text editor. I could understand the need to learn how to manually compile/build in command prompt and alike, but that's not overly difficult, nor needed these days. Each to their own in my opinion.
 
author
Posts: 23959
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Brad Dwan wrote:
Why? I would think being able to know spot syntax errors, use auto-complete and, the constant javadocs features would be extremely helpful to programming novice. I'm new to Java, but not programming and OOP, and using the IDE has allowed me to progress at a much greater rate then a plain text editor. I could understand the need to learn how to manually compile/build in command prompt and alike, but that's not overly difficult, nor needed these days. Each to their own in my opinion.



Its a bit more than using the command line tools. There are some very distinct setup quirks with Java. In my previous company, we sent an "experience" engineer on site, and this engineer could not get the classpath correct (production code obviously are not run by IDEs). It was quite embarrassing.

Henry
 
Moguluri Ravi Kiran
Ranch Hand
Posts: 63
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
String is immutable , means the String object once created can't be changed , But i have small doubt..

we can do

String s = "aa";
s+="bb";

isn't the original object 's' changed ?

Thanks.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Brad Dwan wrote:No offence intended. Why? I would think being able to know spot syntax errors, use auto-complete and, the constant javadocs features would be extremely helpful to programming novice.


Because you learn more, and learn how to learn more quickly, if an IDE isn't holding your hand. In addition, IDE's can *cause* problems that aren't directly related to the learning that's actually going on. It's easier, quicker, and more efficient to attack one set of problems at a time: the more layers are involved the more overwhelming, the more obfuscation, the more things that can go wrong.

Just like if I'm learning a new framework I wouldn't start with a complete application--I'd build it up over time, understanding each component I'm working with, each associated tool, etc. That way if something *does* go wrong I have only a small set of known things to look at, rather than every single item in my tool chain and development process.

I could understand the need to learn how to manually compile/build in command prompt and alike, but that's not overly difficult, nor needed these days.


In order to understand what happens when things go wrong with tools like Ant or Maven a strong grounding in the fundamentals is *mandatory*. If you can't figure out a classpath issue on the command line how are you going to figure it out when there's multiple additional layers of obfuscation?
 
James Elsey
Ranch Hand
Posts: 231
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Moguluri Ravi Kiran wrote:String is immutable , means the String object once created can't be changed , But i have small doubt..

we can do

String s = "aa";
s+="bb";

isn't the original object 's' changed ?

Thanks.



I think that the "internal workings" of the string append, will create a new string, so s+="bb"; would be :



Don't quote me to that, but that makes sense
 
Moguluri Ravi Kiran
Ranch Hand
Posts: 63
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your valuble views.
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Moguluri Ravi Kiran wrote:String is immutable , means the String object once created can't be changed , But i have small doubt..

we can do

String s = "aa";
s+="bb";

isn't the original object 's' changed ?

Thanks.



No, it is not. Without getting into the nitty-gritty details, what happens is a NEW string is created, and the reference variable s is reassigned to point to it. I think you can test this by doing something like



 
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

String s = "aa";
s+="bb";

isn't the original object 's' changed ?



No it is not. To restate Fred's response a little, the object to which the reference variable s pointed still exists but you no longer have a reference to it. The reference variable s now points to a completely separate object whose content is "aabb".

In other words, s is not really an object at all, it's a reference variable that leads to an object. Point that reference variable somewhere else, or set it to null, or let it pass out of scope, and the object is lost unless you have another reference for it. (The object still exists and will eventually be destroyed by the garbage collector.)

If you need to do a lot of String concatenation you should use StringBuilder to avoid leaving a lot of abandoned objects in memory.

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just did this and got:

string t is aa
string s is aabb
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What did you expect to happen?
 
fred rosenberger
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[quote=Lavanya Halliwell]I just did this and got:

string t is aa
string s is aabb[/quote]
exactly. That shows that your original string of "aa" didn't change. It's still there, untouched.

A new, second string of "aabb" was created, and s now points to that.

 
reply
    Bookmark Topic Watch Topic
  • New Topic