How to use scanner for taking inputs in functions
i.e in Java we follow pass by value so,, how will we pass values in calling function parameters via Scanner ....... why below program don't run..what r the errors?? import java.util.Scanner; public class MyClass { public static void main(String[ ] args) { Scanner myVar = new Scanner(System.in); MyClass obj=new MyClass(); int n1=myVar.nextInt(); int n2=myVar.nextInt(); int i=obj.blackJack(n1,n2); System.out.println(i); } public int blackJack(int n1,int n2){ if(n1<=21&&n2<n1) return n1; if(n2<=21&&n1<n2) return n2; if(n1>21&&n2>21) return -1; if(n1==n2&&n1<=21) return -2; if(n1<=21) return n1; if(n2<=21) return n2; return 0; } }