Arrayをパラメータとして受け入れるメソッドdoSomething()
があります。私は怒鳴るような配列渡すとき:Javaのパラメータとして配列を渡すことができません
Exception in thread "main" java.lang.Error: Unresolved compilation problems: Syntax error on token "doSomething", @ expected before this token Syntax error, insert "enum Identifier" to complete EnumHeader Syntax error, insert "EnumBody" to complete BlockStatements
at org.my.ArrayMistry.main(ArrayMistry.java:6)
注:
私は、その後のように怒鳴るそのOK渡す場合:
public static void main(String ... args) {
int[] p = {1,2};
doSomething(p);// no Error
doSomething(new int[]{1,2});// no Error
}
に深く、より問題を説明し、この記事を読む:http://stackoverflow.com/questions/5387643/array-initialization-syntax-when-not-in-a-declaration –