0
public class PassByReference {
    int oneTozero (int arg[]) {
    }
}

I've never seen a variable declared this way. Can someone explain? Thanks

YetAnotherBot
  • 1,937
  • 2
  • 25
  • 32
Sil
  • 1

4 Answers4

1

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[].

Ashish Yadav
  • 1,901
  • 2
  • 17
  • 23
1

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[].

Thilo
  • 257,207
  • 101
  • 511
  • 656
0

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
uli
  • 671
  • 6
  • 15
0
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.

Oleg Cherednik
  • 17,377
  • 4
  • 21
  • 35