Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

share state?????

 
Leandro Oliveira
Ranch Hand
Posts: 298
  • 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
  • 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
  • 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
  • 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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic