diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..7454180 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..2e6e589 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/src/main/kotlin/Demo1/InitAndSingleton.kt b/src/main/kotlin/Demo1/InitAndSingleton.kt new file mode 100644 index 0000000..717eec8 --- /dev/null +++ b/src/main/kotlin/Demo1/InitAndSingleton.kt @@ -0,0 +1,39 @@ +package Demo1 + +class InitAndSingleton{ + //初始化 + init{ + println("init") + } + //带参构造方法 + constructor(data:String){ + println("data = ${data}") + } + //构造方法 + constructor(){ + println("not parma") + } + + //定义静态方法 + companion object{ + //方法实现 + fun function() { + println("is Function") + } + } + +} + +fun main() { + InitAndSingleton() + InitAndSingleton("uname") + InitAndSingleton.function() + +} +/** out ** +init +not parma +init +data = uname +is Function + **/ \ No newline at end of file diff --git a/src/main/kotlin/InitAndSingleton.kt b/src/main/kotlin/InitAndSingleton.kt deleted file mode 100644 index 9f09432..0000000 --- a/src/main/kotlin/InitAndSingleton.kt +++ /dev/null @@ -1,13 +0,0 @@ -class InitAndSingleton{ - //初始化 - init{ - println("init") - } - //定义静态方法 - companion object{ - //方法实现 - fun function(){ - - } - } -} \ No newline at end of file