/* Program to illustrate various approaches for storing and accessing 
   strings in Java */

public class stringExample
{ public static void main (String [] args)
    {   String s = "abcdefghi";
        String a;
        String b;
        String c;
        String d;
        
        /* initialization */
        a = s;
        b = a;
        c = "uvwxyz";
        d = c;
        
        /* print initial values */
        System.out.println ("Initial values of variables");
        System.out.println ("   s:  " + s);
        System.out.println ("   a:  " + a);
        System.out.println ("   b:  " + b);
        System.out.println ("   c:  " + c);
        System.out.println ("   d:  " + d);

        /* modify some variables */
        s = s.substring(0,3) + 'm' + s.substring(4, 9);
        a = a.substring(0,5) + 'p' + s.substring(6, 9);
        c = c.substring(0,1) + 'k' + c.substring(2, 6);

        /* print after modifications */
        System.out.println ("Values of variables after a and c changed");
        System.out.println ("   s:  " + s);
        System.out.println ("   a:  " + a);
        System.out.println ("   b:  " + b);
        System.out.println ("   c:  " + c);
        System.out.println ("   d:  " + d);
        
    }
}
