• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java String has all attributes marked as final except hash field  RSS feed

 
sai rama krishna
Ranch Hand
Posts: 536
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am reading below paper
http://javapapers.com/core-java/java-string/
i am not clear on below statement

Java String has all attributes marked as final except hash field.



Is comparator is a field(class level variable) in String?
i see String implements Comparable interface though.

I see String is Final
but when author said all Fields in String are Final except hash. I have not understood. please advise
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means that all the member variables of class String (except the hash field) are final.

You can check this by looking at the source code of class String. You can find the source code of class String in the file src.zip which is in your JDK installation directory.
 
sai rama krishna
Ranch Hand
Posts: 536
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am here
C:\Program Files (x86)\Java\jdk1.6.0_25
From here where to go to find src.zip

i checked
C:\Program Files (x86)\Java\jdk1.6.0_25\src\java\util
I see StringTokenizer but not String
I wonder why API does not show the fields.
please advise
 
Paweł Baczyński
Bartender
Posts: 2086
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String is in java.lang package, not java.util.

Why would you want to see private fields in javadocs? They are private for a reason.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since the hash code does not form part of the String displayed, and since it is lazily initialised before it is needed, knowing whether it is final or not is of no practical use. I have already told you I don't consider those tutorials good.
 
sai rama krishna
Ranch Hand
Posts: 536
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
which java j2ee paper site is validated and some what error proof. please advise
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That last post doesn't make sense.
 
sai rama krishna
Ranch Hand
Posts: 536
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mean which website has java papers which are verified before posting?
I wonder if any websites like that available.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know. Maybe somebody else will.

We have things validated on this website, but usually only after posting
 
sai rama krishna
Ranch Hand
Posts: 536
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i see.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means you will get accurate information here, but only after everybody has had a chance to read the thread and comment on it
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!