// StringDemos.java
// Examples of some common String class methods
import java.awt.*;
import javax.swing.*;

public class StringDemos extends JApplet {
	String school = "Lehigh University";
	String b = "   Jack & Jill                    ";
	public void paint( Graphics g ) {
		g.drawString( "The first occurence of 'i' is " + school.indexOf( 'i' ), 25, 25 );
		g.drawString( "The next occurence of 'i' is " + school.indexOf( 'i', 6 ), 25, 50 );
		g.drawString( "The last occurence of 'i' is " + school.lastIndexOf( 'i' ), 25, 75 );
		g.drawString( "The next to last occurence of 'i' is " + school.lastIndexOf( 'i', 12 ), 25, 100 );
		g.drawString( "The second occurence of 'i' is " + school.indexOf( 'i', school.indexOf( 'i' ) + 1 ), 25, 125 );
		g.drawString( "The first occurence of \" U\" is " + school.indexOf( " U"), 25, 150 );
		g.drawString( "The last occurence of \"eh\" is " + school.lastIndexOf( "eh" ), 25, 175 );

		g.drawString( "The substring from index 8 is " + school.substring( 8 ), 25, 200 );
		g.drawString( "The substring from index 2 to 4 is " + school.substring( 2, 5 ), 25, 225 );
		g.drawString( "A substring of the first 6 characters is " + school.substring( 0, 6 ), 25, 250 );
		
		g.drawString( "All CAPS version is " + school.toUpperCase( ), 25, 275 );
		g.drawString( "A trimmed b is " + b.trim( ) + ".", 25, 300 );
		b = b.trim( );
		b = b.concat(" went up the hill" );
		g.drawString( b, 25, 325 );
		b += " to fetch a pail of water.";
		g.drawString( b, 25, 350 );
	}
}