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