So I'm making a Java Util and I am stuck on this part of code.
public void getInput(String i){
int i = scan.nextInt()
}
Why won't this work?
So I'm making a Java Util and I am stuck on this part of code.
public void getInput(String i){
int i = scan.nextInt()
}
Why won't this work?
i
is already declared as String
yet you redeclare i
as an int
. That can't work!
You have two variables, which has the same name i
but has the different type.
Change it like,
public void getInput(String i){
int data = scan.nextInt();
}
and the Complier error will be gone.