public class PassByReference {
int oneTozero (int arg[]) {
}
}
I've never seen a variable declared this way. Can someone explain? Thanks
public class PassByReference {
int oneTozero (int arg[]) {
}
}
I've never seen a variable declared this way. Can someone explain? Thanks
It's not a variable, you have a class called PassByReference
with method type integer oneTozero
and an integer array as an argument to that method arg[]
.
If the confusion is about int arg[]
vs int[] arg
, that is an alternative syntax to specify arrays for people coming from C.
It means the same thing.
And, yes, it's confusing, especially if you mix the two int[] twoDim[]
.
int oneTozero (int arg[]) {}
describe the method.
int arg[]
is an parameter. It is an array of int. In Java there are at least 3 ways to describe parameter as an array and all of them are equal:
int array[]
int[] array
int... array
public class PassByReference {
int oneTozero (int arg[]) {
}
}
New class PassByReference
with public
visibility is been declared. This class contains oneTozero
method with default
visibility and array of integer as argument.