• Post Reply Bookmark Topic Watch Topic
  • New Topic

creating an accessor and mutator for a dual array  RSS feed

 
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
 
Sheriff
Posts: 11752
191
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

 
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?
 
Marshal
Posts: 58454
178
  • 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: 58454
178
  • 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: 58454
178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are welcome
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!