/* String
 * - allow you to manipulate sequences of characters
 * - consists of a sequence of characters. 
 *	"This" has 4 characters, character 0 is "T"
 *	character 1 is "h", character 2 is "i", character 3 is "s"
 * - methods include 
 * 	int length() - return the length of the string
 * 	String concat(String str) - put together with str
 * 	String substring(int beginindex) - return the string
 * 		beginning at beginindex and ending at the
 * 		end of the string
 * 	String substring(int beginindex, int endindex)
 * 		return the string beginning at beginindex and
 * 		ending at endindex
 * 	indexOf(String str) - find the location of str
 * 	indexOf(String str, int startindex) - find the location
 * 		of str starting at startindex
 */

class StringDemo {
	public static void main(String [] args){
		// create a reference to a string and associate it
		// with a string (3 different ways.)
		String s1; 
		s1=new String("Hi There! I'm here."); 

		String s2="ABCDEFGHIJKLM";
		String s3=new String("123456789");

		System.out.println(s3.length());
		System.out.println(s2.substring(0));
		System.out.println(s2.substring(2));
		System.out.println(s2.substring(2,5));
		// System.out.println(s2.substring(2,55)); Causes error!!

		String s4;
		s4=s2.concat(s3); 
		System.out.println(s4);
		s4=s2+s3; // Does the same as above
		System.out.println(s4);
		s4=s2.substring(2,5)+s3.substring(3,7);
		System.out.println(s4);

		System.out.println("Looking for ere in s1");
		System.out.println("Start at 0, found at "+s1.indexOf("ere"));
		System.out.println("Start at 0, found at "+s1.indexOf("ere",0));
		System.out.println("Start at 2, found at "+s1.indexOf("ere",2));
		System.out.println("Start at 5, found at "+s1.indexOf("ere",5));
		System.out.println("Start at 7, found at "+s1.indexOf("ere",7));
		System.out.println("Start at 9, found at "+s1.indexOf("ere",9));
		System.out.println("Start at 17, found at "+s1.indexOf("ere",17));
	}
}
