• Post Reply Bookmark Topic Watch Topic
  • New Topic

creating an accessor and mutator for a dual array  RSS feed

 
C C Campbell
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am familiar with creating accessors and mutators but can someone give me an example of how to create them for dual arrays? I need the dual arrays to be int
 
Junilu Lacar
Sheriff
Posts: 11476
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "dual arrays"? Can you give a code example that uses dual arrays?
 
C C Campbell
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu, my mistake I don't need it for a dual array just an array

 
Gabriel John Gagno
Greenhorn
Posts: 5
IntelliJ IDE Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isn't it as simple as making a getter/setter method?
 
Campbell Ritchie
Marshal
Posts: 56522
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is one way to do it. But it is very insecure because you now have two references to the arrayYou can reduce the risk of such errors with the clone() method, which all arrays implement. That will only work reliably unchanged for an ordinary (one‑dimensional) array of primitives or immutable reference types.
 
Campbell Ritchie
Marshal
Posts: 56522
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is not called a dual array. It is an array of arrays.
 
C C Campbell
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all
 
Campbell Ritchie
Marshal
Posts: 56522
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are welcome
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!