udayshankar kintali wrote:yeah something similar like
Does that make it clear?
udayshankar kintali wrote:view plaincopy to clipboardprint?
int a = 1;
int b = 2;
This is easy:
temp = a;
a=b;
b=temp;
Exact situation: I have an ArrayList of int[]
Then took two temp
ArrayList<int[]> swap1 = new ArrayList<int[]>();
ArrayList<int[]> swap2 = new ArrayList<int[]>();
But when I tried to iterate over the swap1 I was just getting addresses but I want to access the elements.
udayshankar kintali wrote:I was printing the Object.
// swaps element at position n in two arrays
void swap(int[] arr1, int[] arr2, int index) {
// code to swap elements at a single index goes here
for(int i = 0 ; i< arr1.lenth;i++)
{
if(i>=index)
{
temp = arr1[i];
arr1[i]=arr2[i];
arr2[i]=temp;
}
}
Isn't that right??
udayshankar kintali wrote:Without the if test how would you know from where to start the swapping.
The Sysoout printed :
pos9
[I@5013582d
[I@26021b6d
[I@5013582d
[I@26021b6d
udayshankar kintali wrote:
I used this to iterate over and print...but it prints the same thing. Where can I use , or call java.util.Arrays.toString() or deepToString().
udayshankar kintali wrote:Jeff,
When we pass [][](2-D) array as a parameter to a function and in that function we make some changes, the changes will be reflected in the actual array right.
So, I am actually sending the base address.
No, you haven’t. There’s no such thing. You have an array of arrays.udayshankar kintali wrote: . . .
Now I have a two dimensional array . . .