public class StringTest
{
public static void main(String[] args)
{
method_tran();
}
public static void method_tran()
{
String s="Hello Java";
sop(s.toLowerCase());
sop(s.toUpperCase());
method(s);
}
public static void sop(Object obj)
{
System.out.println(obj);
}
public static void method(String str){
String s1 = str.substring(0, 1); //截取H
String s2 = str.substring(1,6); //ello
String s3 = str.substring(6,7); // 截取 j
String s4 = str.substring(7,10); //截取ava
String s5 = s1.toLowerCase() + s2.toUpperCase()+s3.toLowerCase()+s4.toUpperCase();
System.out.println(""+s5);
}
} |