Thursday, October 9, 2008

Java - Check String

//
// CheckString.java
//
public class CheckString
{
public static void main(String arguments[])
{
// create an object

//String str = "Roses are red" ;
String str = new String("Roses are red");

System.out.println(" 1 ");
System.out.println("0123456789012");
System.out.println("Roses are red");
System.out.println(" ");

System.out.println("String is : " + str);
System.out.println("Length is : " + str.length());
System.out.println("Position 3 is : " + str.charAt(3));
System.out.println("Pos 6-9 is : " + str.substring(6, 9));
System.out.println("Char 'a' is at : " + str.indexOf('a'));
System.out.println("\"red\" word at : " + str.indexOf("red"));
System.out.println("Upper case : " + str.toUpperCase());
System.out.println("Lower case : " + str.toLowerCase());
}
}

No comments:

Post a Comment