This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

share state?????

 
Leandro Oliveira
Ranch Hand
Posts: 298
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'Values of the primitive types do not share state'
what does this mean???
Sorry if it is a too stupid question!!! but, I'm not very good with english!!! here in my country isn't easy to find good forums!!!
 
marilyn murphy
Ranch Hand
Posts: 84
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Primitive values do not share state with other primitive values.jls 4.2
Don't feel bad, it's not an easy statement for a native English speaker either.
 
marilyn murphy
Ranch Hand
Posts: 84
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The state of an object typically contains
references to other objects.

However a primitive cannot contain anything but the primitive value of that type. It cannot contain references to another primitive.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The idea is simple, and you may likely understand it already. An example that further illustrates the concept:
If a variable i of type int is declared and given it an initial value 0, and another int variable j is declared and assigned the value of i, then both variables would have the value 0. If i is later assigned a different value such as 1, the value of j is not affected - j would still be 0.Making sense?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic