Kotlin Examples ❮ 上一页 下一个 ❯ Kotlin Syntax and Output Output some text Output text on new lines Do a simple calculation Output some text with the print() function Output Explained Kotlin 评论 Single-line comment before a line of code Single-line comment at the end of a line of code Multi-line comment Comments Explained Kotlin 变量 Create two variables Create two variables and specify the data type Declare a variable without assigning the value Create variable that cannot be changed/reassigned Combine both text and a variable Add a variable to another variable Variables Explained Kotlin 数据类型 Create different variables of different types Create different variables of different types explicitly Create a Byte type variable Create a Short type variable Create an Int type variable Create a Long type variable Create a Float type variable Create a Double type variable Create a Boolean type variable Create a Char type variable Create a String type variable Type conversion - Convert a data type to anoter type Data Types Explained Kotlin 运算符 Addition operator Subtraction operator Multiplication operator Division operator Modulus operator Increment operator Decrement operator Assignment operator Equal operator Not equal operator Greater than operator Less than operator Greater than or equal to operator Less than or equal to operator Logical and operator Logical or operator Logical not operator Operators Explained Kotlin 字符串 Create a string Create a string and specify the type Access a string Find the length of a string Compare two strings Find a string in a string Concatenate/merge two strings Concatenate/merge two strings with the plus() function Use quotes inside a string Strings Explained Kotlin 布尔值 Create a boolean Creation a boolean and specify the type Compare two values Booleans Explained Kotlin If...Else The if statement The else statement The else if statement If..else expression Shorthand if..else If...Else Explained Kotlin 何时 The when expression When Explained Kotlin While 循环 Loop through a block of coding using a while loop Loop through a block of coding using a do/while loop While Loop Explained Kotlin Break/continue Jump out of a loop with the break statement Skip a value in a loop with the continue statement Break/continue Explained Kotlin 数组 Create and access an array Change an array element Find the length/size of an array Check if an element exists in an array Loop thourh an array Arrays Explained Kotlin For Loops Loop through an array of strings Loop through an array of integers For loop Explained Kotlin 范围 Create a range of characters Create a range of numbers Check if a value exists in a range Using the break statement in a range Using the continue statement in a range Ranges Explained Kotlin 函数 Create a function and call it Call a function multiple times Create a function with parameters Using the return keyword in a function Shorthand syntax for return values Functions Explained Kotlin 类 Create a class and an object of that class Create multiple objects of one class Create a constructor Create a class function Create a class function with parameters Create a class that should inherit properties of a parent class (inheritance) Classes Explained ❮ 上一页 下一个 ❯