/* Continents.java (c) Kari Laitinen http://www.naturalprogramming.com 2016-09-21 File created. 2016-09-25 Last modification. This program shows how some common String methods work. - charAt() returns the character in the indexed position - 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. */ class Continents { public static void main( String[] not_in_use ) { String indexes = "01234567890123456789012345678901234567890123456" ; String continent_names = "America Europe Africa Asia Australia Antarctica" ; System.out.print( "\n " + indexes ) ; System.out.print( "\n " + continent_names + "\n" ) ; System.out.print( "\n " + continent_names.charAt( 8 ) ) ; System.out.print( "\n " + continent_names.indexOf( "ia" ) ) ; System.out.print( "\n " + continent_names.lastIndexOf( "ia" ) ) ; System.out.print( "\n " + continent_names.indexOf( "Atlantis" ) ) ; System.out.print( "\n " + continent_names.substring( 15, 26 ) ) ; System.out.print( "\n " + continent_names.substring( 27 ) ) ; System.out.print( "\n " + continent_names.substring( 27 ) + continent_names.substring( 0, 27 ) ) ; System.out.print( "\n " + continent_names.replace( "ica", "XXX" ) ) ; System.out.print( "\n " + continent_names.toUpperCase() ) ; System.out.print( "\n\n" ) ; } }