riku
2025-10-30 e9aa93f381afcf9f9cf0c39f2b9e32375ed49528
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package cn.flightfeather.thirdappmodule
 
import com.google.gson.Gson
import org.junit.Test
 
/**
 * @author riku
 * Date: 2019/7/29
 */
class Test {
 
    @Test
    fun foo1() {
        val l1 = arrayListOf<Int>(1, 2, 3, 4, 5)
        val l2 = ArrayList<Int>()
 
//        l2.add(l1[0])
//        l2.add(l1[1])
        l2.addAll(l1)
 
        l2[0] = 7
        l2[1] = 8
 
        l1.forEach {
            print("$it,")
        }
        l2.forEach {
            print("$it,")
        }
    }
 
    @Test
    fun foo2() {
        val s1 = "foo#aab#shad#asdasd"
        val r = s1.replace("#", "、")
        println(r)
    }
 
    @Test
    fun foo3() {
        val list = listOf("u1", "u2", "u3")
        val s = Gson().toJson(list)
        println(s)
    }
 
    @Test
    fun foo4() {
        val list = listOf(1, 2, 3)
        list.toMutableList().clear()
        println(list)
    }
}