Valid Java code that is NOT valid Groovy code?

后端 未结 8 2060
忘了有多久
忘了有多久 2020-12-05 04:50

Most Java code is also syntactically valid Groovy code. However, there are a few exceptions which leads me to my question:

Which constructs/features in Java are syn

8条回答
  •  醉梦人生
    2020-12-05 05:45

    Declaring an array of a given type using [] after the variable name instead of the type works in Java but not Groovy.

    byte[] buff = new byte[1024]; // Works

    byte buff[] = new byte[1024]; // Not Groovy

    Results in Primitive type literal: byte cannot be used as a method name

提交回复
热议问题