Kotlin asterisk operator before variable name or Spread Operator in Kotlin

后端 未结 5 723
猫巷女王i
猫巷女王i 2020-11-30 00:59

I want to know what exactly an asterisk does before a variable name in Kotlin. I saw this (*args) in a Spring boot Kotlin example:

@SpringBootApp         


        
5条回答
  •  无人及你
    2020-11-30 01:29

    In Java you can pass an array as is but an advantage of unpacking an array with spread operator * is that spread operator lets you combine the values from an array and some fixed values in a single call. Java doesn't support this.

提交回复
热议问题