Originally Posted by
netlync
I would like to know why I can't return two variables in one method. I can pass only one variable.
Eg;
protected int getData(){
System.out.print("Enter num1");
Scanner scan=new Scanner(System.in);
int num1=scan.nextInt();
System.out.print("Enter num2");
int num2=scan.nextInt();
return num1,num2;
}
From what I have heard, usually when you want to return more then one variable it is a hint that you need to rethink how you are doing things. I dont know if that is true or not personally, since I have not used any language that supports it (python kind of supports it and I have used that language).