标签:ati span 反转 aaa com == java pre 要求
目录
1.字符串反转
public class 字符串反转 { public static String ReverseSentence(String str) { String[] chars=str.split(" "); if (chars.length<=1) return str; String newstr=""; for(int i=chars.length-1;i>=0;i--){ if(i==0) newstr+=chars[i]; else newstr+=chars[i]+" "; } return newstr; } public static void main(String[] args) { String str="how are you"; System.out.println(ReverseSentence(str)); } }
2.字符串含相同字符
import java.util.Arrays; public class 字符串所有组合 { public static void compare(String s1,String s2){ byte[] b1=s1.getBytes(); byte[] b2=s2.getBytes(); Arrays.sort(b1); Arrays.sort(b2); s1=new String(b1); s2=new String(b2); if(s1.equals(s2)) System.out.println("equals"); else System.out.println("not equals"); } public static void main(String[] args){ String str1="aamgaabbc"; String str2="mbabaaacg"; compare(str1,str2); str1="aamgasabbc"; str2="ksbbbaacc"; compare(str1,str2); } }
3.删除重复字符
4.统计单词
5.按要求打印数组排列
6.字符串所有组合
标签:ati span 反转 aaa com == java pre 要求
原文地址:https://www.cnblogs.com/jocelynD-9/p/11520700.html