I'm newbie to java. I have a global array
defined as private int dataRightTemp[]=new int [4];
and in the middle of the code, this array
is being passed to a method as a argument(below I have attached the code). Within this new method the values of the prior global array
which is dataRightTemp
is being changed from a calculation which uses the passed array in theparameters
of the method. When the calculation is finished, and new values are set to the dataRightTemp
, how is the values of thearray
in parameters
of the method be changed, Can anyone help me to figure this out. Thanks in advance.
public class Demo{
private int key[]={1,0,1,0};
private int dataBlock[]={1,1,1,0,1,0,1,1};
private int dataLeft[]=new int [4]; // for left part the plain text
private int dataRight[]=new int [4]; //for right part of the plain text
private int dataLeftTemp[];
private int dataRightTemp[]=new int [4];
public void roundingStart(){
for(int i=0;i<4;i++){
// AND function
dataRightTemp[i]=key[i] & dataRight[i];
// XOR function
dataRightTemp[i]=dataRightTemp[i]^dataLeft[i];
}
dataLeft=dataRight.clone();
// printResults();
printFirst();
roundingRest(dataLeft,dataRightTemp);
}
public void roundingRest(int leftArray[],int rightArray[]){
System.out.println("Before");
for(int x: rightArray){
System.out.print(x);
}
System.out.println();
for(int i=0;i<4;i++){
// AND function
dataRightTemp[i]=key[i] & rightArray[i];
// XOR Function
dataRightTemp[i]=dataRightTemp[i]^leftArray[i];
}
System.out.println("right after");
for(int x: rightArray){
System.out.print(x);
}
System.out.println();
System.out.println();
}
public void main(String args[]){
roundingStart();
}
}
Following are the received outputs:
Before
0100
After
1011