Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing variables in an array element

 
Malcolm White
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,
I have an array which is an instance of a class and is made up of 10 elements (indeces). The class that it is an instance of has two private variables. What I'm trying to do is that after the elements are populated in the array, I want to swap two of them around.
Is there a way to use a syntax like:
int first_value=array[3].value1
int second_value=array[3].value2
to get the two parts (variables) of the element in differenet variables of primitive types?
The above code doesn't seem to work. I remember being able to use "dot" after an object to access both its functions and variables. Thanks to all who can help.
Regards.
[ November 29, 2002: Message edited by: Malcolm White ]
 
James Chegwidden
Author
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would help if you could post your code. We could probably help better.
 
Malcolm White
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. Here's my code


The 'Card' class has two private variables declared in it: value and suit.
Hope someone can help. Thanks.
[ November 29, 2002: Message edited by: Malcolm White ]
[ November 29, 2002: Message edited by: Malcolm White ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic