Refine kotlin code (#1241)

* style(kotlin): Improve kotlin codes readability.

* remove redundant quotes.

* style(kotlin): improve codes readability.

* style(kotlin): refine kotlin codes.

* Create kotlin.yml

* Create kotlin.yml

* Delete .github/workflows/kotlin

* Delete .github/workflows/main.yml

* Create kotlin.yml

* Update kotlin.yml

* Delete .github/workflows/kotlin.yml

* Create hello_world_workflow.main.kts

* Delete .github/workflows/hello_world_workflow.main.kts

* remove empty line
This commit is contained in:
curtishd
2024-04-09 16:26:58 +08:00
committed by GitHub
parent 41dd677338
commit 896d9a64f6
22 changed files with 158 additions and 112 deletions

View File

@@ -9,7 +9,7 @@ package chapter_stack_and_queue
/* 基于数组实现的栈 */
class ArrayStack {
// 初始化列表(动态数组)
private val stack = ArrayList<Int>()
private val stack = mutableListOf<Int>()
/* 获取栈的长度 */
fun size(): Int {
@@ -40,7 +40,7 @@ class ArrayStack {
/* 将 List 转化为 Array 并返回 */
fun toArray(): Array<Any> {
return stack.toArray()
return stack.toTypedArray()
}
}
@@ -63,7 +63,7 @@ fun main() {
/* 元素出栈 */
val pop = stack.pop()
println("出栈元素 pop = ${pop},出栈后 stack = ${stack.toArray().contentToString()}")
println("出栈元素 pop = $pop,出栈后 stack = ${stack.toArray().contentToString()}")
/* 获取栈的长度 */
val size = stack.size()