JAVA面试题-STRINGBUFFER倒序输出、正则将首字母大写

 
package com.zzk.test;

//将This is a test倒着输出tset a si sihT(用StringBuffer)

public class Test{
	public static void main(String[] args) {
		StringBuffer s=new StringBuffer("This is a test");
		System.out.println(s.reverse());
	}
}


输出:

tset a si sihT

 

 

package com.zzk.test;

//将this is a test转化为This Is A Test

public class Test {
	public static void main(String[] args) {
		String s="today is nice hahaha";
		String arr[]=s.trim().split("\\s+");
		if(s.length()>0)
			for(int i=0;i<arr.length;i++) {
				arr[i]=Character.toUpperCase(arr[i].charAt(0))+arr[i].substring(1);
				System.out.print(arr[i]+" ");
			}
	}
}


输出:

 Today Is Nice Hahaha

 

 

上一篇:raid5 /raid5e /raid5ee的性能对比及raid数据恢复原理


下一篇:Android实现系统下拉栏的消息提示——Notification