When you do Type[] arr = { …, … };
that’s an array initializer. It can only be used in array declarations (or in array creation expressions, i.e. new String[]{"a", "b"}
).
Arrays.asList
is defined to take varargs arguments (asList(T... a)
), so you do not have to wrap your arguments in an array first: Arrays.asList("text", "tek1")
will already implicitely create an array from your arguments and pass this to the method.
solved Syntax error on token “.”, @ expected after this token [duplicate]