题目Median of Two Sorted Arrays(难度Hard) 方案1,数组合并&排序调用Java方法 import java.util.* class Solution { fun findMedianSortedArrays(nums1: IntArray, nums2: IntArray): Double { val lenNums1 = nums1.size val lenNums2 = nums2.size val array = Arrays.copyOf(nums1,
不积跬步无以至千里,不积小流无以成江海 先看看Kotlin中for循环的遍历 fun testList(){ var StringVal = "12_12_13_15_a_b_c_d_yu_er" var ssArray = StringVal.split("_") var ss01 = ssArray[0] var ss02 = ssArray[1] var size = ssArray.size println("ss01: $ss01")
上一篇文章提到泛型函数appendString是在类外面定义,这不免使人疑惑,类里面又该怎样定义成员函数呢?为解答这个疑问,接下来的几篇文章将好好描述一下Kotlin如何操作类及其对象,本篇文章先对类的定义进行说明并加以运用. 之前我们已经多次见过的类MainActivity,在Java代码中该类的写法如下所示: public class MainActivity extends AppCompatActivity { } 而对应的Kotlin代码是下面这样的: class MainActivi
Kotlin Koans 心印 Introduction 1.Hello, world! Simple Functions Take a look at function syntax and make the function start return the string "OK". In the tasks the function TODO() is used that throws an exception. Your job during the koans will be