how to pass parameters from a method to another which accepts to parameters?possible?
in this code, i would like to know how to pass the convertedWorkArray from the first method to the second one ??
N.B:
both methods belong to the same class
i dont want the method ( getsum) to receive any parameters from the (main), i just want to know how to set the (convertedworkarray) visible to the method (getsum)
Code:
public int []convertStrToInt()
{
int [] [COLOR="Red"]convertedWorkArray[/COLOR] = new int [workarray.length];
for (int i=0;i<workarray.length;i++)
convertedWorkArray[i]=Integer.parseInt(workarray[i]);
System.out.println("Your array was converted into integers");
return convertedWorkArray;
}
public int getSum()
{
int sum=0;
for (int i=0 ; i<[COLOR="red"]convertedWorkArray[/COLOR].length ; i++)
sum+ = convertedWorkArray[i];
return sum;
}
public static void main (String [] args)
{
Op obj = new Op();
Scanner read = new Scanner (System.in);
String scanchoice;
int size, choice,value;
do
{
System.out.println("choose an operation: 1:+ 2:- 3:* 4:/");
scanchoice = read.nextLine();
choice = Integer.parseInt(scanchoice);
switch (choice)
{
case 1 : System.out.println("enter number of elements:");
value=read.nextInt();
obj.setsize(value);
obj.initialize();
obj.getnumofoperands();
obj.[COLOR="Red"]convertStrToInt[/COLOR]();
System.out.println("Thu Sum = "+obj.[COLOR="Red"]doSum());[/COLOR]
/* pluseop(operand1,operand2);
case '2' : initialize();
subop(operand1,operand2);
case '3' : initialize();
mulop(operand1,operand2);
case '4' : initialize();
divop(operand1,operand2);*/
}// end switch
} while(choice!=1 || choice!=2 || choice!=3 || choice!=4); // end do-while
} // end main
} //end class