collections/List.kt
This commit is contained in:
		
							parent
							
								
									9a7ae56256
								
							
						
					
					
						commit
						04adb2ab3a
					
				
							
								
								
									
										19
									
								
								kotlinstudy/collections/List.kt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								kotlinstudy/collections/List.kt
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
				
			|||||||
 | 
					package kotlinstudy.collections
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fun main() {
 | 
				
			||||||
 | 
					    val readOnlyShapes = listOf("triangle", "square", "circle")
 | 
				
			||||||
 | 
					    println(readOnlyShapes)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    println("The 1st item in the list `readOnlyShapes` is: ${readOnlyShapes[0]}")
 | 
				
			||||||
 | 
					    println("The last item in the list `readOnlyShapes` is: ${readOnlyShapes.last()}")
 | 
				
			||||||
 | 
					    println("The list `readOnlyShapes` has ${readOnlyShapes.count()} items")
 | 
				
			||||||
 | 
					    println("circle" in readOnlyShapes)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    val shapes: MutableList<String> = mutableListOf("triangle", "square", "circle")
 | 
				
			||||||
 | 
					    println(shapes)
 | 
				
			||||||
 | 
					    shapes.add("pentagon")
 | 
				
			||||||
 | 
					    println(shapes)
 | 
				
			||||||
 | 
					    shapes.remove("circle")
 | 
				
			||||||
 | 
					    println(shapes)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user