I'm just beginning to learn java and I'm figuring out method calls. I wrote the code below, so the method 'calling' uses the method 'called' to add 1 to 'number', but it doesn't seem to be executing properly. here's the code:
private void calling(){
int number1 = 4;
int number2 = 2;
called(number1);
System.out.println("number1 = " + number1);
System.out.println("number2 = " + number2);
}
private void called(int number1){
number1++;
}
and then the output I want is 'number1 = 5' & 'number2 = 2', but instead i'm getting this:
number1 = 4
number2 = 2
is there something I'm missing? thanks in advance!