Weird “[]” after Java method signature

后端 未结 4 1182
北海茫月
北海茫月 2020-12-23 08:48

I looked at some Java code today, and I found some weird syntax:

public class Sample {
  public int get()[] {
    return new int[]{1, 2, 3};
  }
}

4条回答
  •  甜味超标
    2020-12-23 09:20

    That's a funny Question. In java you can say int[] a;, as well as int a[];.
    From this perspective, in order to get the same result just need to move the []
    and write public int[] get() {.
    Still looks like the code came from an obfuscator...

提交回复
热议问题