import javax.swing.JOptionPane;
/*
 * Created on May 17, 2004
 * @author Bill Kraynek
 */

public class StringExample3 {
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        String s1 = "abcdef";
        int s1Len = s1.length();
        String s2 = s1.substring(3);
        String s3 = s1.substring(2,5);
        String s4 = s1.replace("ab","def");
        String s5 = s4.replace('d','z');
        String out = s1 + "\n" + "s1 length = " + s1Len + "\n" + s2 + "\n" + s3 + "\n" + s4 + "\n" + s5 + "\n";
        JOptionPane.showMessageDialog(null,out);
        String aName = JOptionPane.showInputDialog("Enter your full name. Separate first and last with one space");
        // if the user clicks on the cancel button then null is returned so quit
        if( aName == null ) return;
        int indexOfSpace = aName.indexOf(' ');
        out = "First = " + aName.substring(0,indexOfSpace) + "\n";
        out = out + "Last = " + aName.substring(indexOfSpace+1) + "\n";
        JOptionPane.showMessageDialog(null,out);
    } // end main
    
} // end StringExample3

