/* Continents.kt Copyright (c) Kari Laitinen http://www.naturalprogramming.com 2020-10-30 File created. This program shows how some common Kotlin String methods work. - indexOf() returns the index of the first occurrence of a substring - lastIndexOf() retruns the index of the last occurrence of a substring - substring() returns the specified substring - replace() replaces all occurrences of a substring - toUpperCase() returns a string in which all letters are converted to upper case if necessary. */ fun main() { val indexes = "01234567890123456789012345678901234567890123456" ; val continent_names = "America Europe Africa Asia Australia Antarctica" ; print( "\n " + indexes ) print( "\n " + continent_names + "\n" ) print( "\n " + continent_names[ 8 ] ) print( "\n " + continent_names.indexOf( "ia" ) ) print( "\n " + continent_names.lastIndexOf( "ia" ) ) print( "\n " + continent_names.indexOf( "Atlantis" ) ) print( "\n " + continent_names.substring( 15, 26 ) ) print( "\n " + continent_names.substring( 27 ) ) print( "\n " + continent_names.substring( 27 ) + continent_names.substring( 0, 27 ) ) print( "\n " + continent_names.replace( "ica", "XXX" ) ) print( "\n " + continent_names.toUpperCase() ) print( "\n\n\n" ) }