public class Main
{
public static void main(String[] args)
{//来 自 时代Java - N o w J a v a . c o m
String s1 = "hello";
String s2 = "GOODBYE";
String s3 = " spaces ";
System.out.printf("s1 = %s\ns2 = %s\ns3 = %s\n\n", s1, s2, s3);
// test method replace
System.out.printf(
"Replace 'l' with 'L' in s1: %s\n\n", s1.replace('l', 'L'));
// test toLowerCase and toUpperCase
System.out.printf("s1.toUpperCase() = %s\n", s1.toUpperCase());
System.out.printf("s2.toLowerCase() = %s\n\n", s2.toLowerCase());
// test trim method
System.out.printf("s3 after trim = \"%s\"\n\n", s3.trim());
/** 来 自 N o w J a v a . c o m**/
// test toCharArray method
char[] charArray = s1.toCharArray();
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。