Generic Classes
Classes in Kotlin can have type parameters to create generic classes, just like in Java // File: Main.kt // Programmer: Engineer Nolverto Urias Obeso // Creation Date: 06/24/2023 // Email: nolvertou@gmail.com // Description: Using generic classes fun main () { val stringList: MyList<String> // Using generic Class val intList: MyList<Int> = MyList() intList.addItem( 1 ) println (intList.get( 1 )) } class MyIntList{ fun get (pos: Int) : Int{ return 0 } fun addItem (item: Int){} } class MyShortList{ fun get (pos: Int): Short{ return 0 } fun add (item: Short){} } // Generic Class class MyList< T >{ fun get (pos: T ): T { // TODO("implement") return pos } fun addItem (item: T ){} } Example 2: Main.kt import generics.Aquarium // File: Main.kt // Programmer: Engineer Nolverto Urias Obeso // Creation Date: 06/24/2023 // Email: nolvertou@gmail.c...