wmjy.net
当前位置:首页 >> string 去掉重复 >>

string 去掉重复

String aa = "qq,gg,ff,qq,kk,11,qq,28,qq"; String aaArray[] = aa.split(","); HashSet hs = new HashSet(); for(String s : aaArray){ hs.add(s); } Iterator it = hs.iterator(); if(it.hasNext()){ String aa_ = hs.toString().replace("["...

import java.util.Set; import java.util.TreeSet; public class Admin { public static void main(String[] args) { String fdbs = "WXB,WXA,FDA,WXB"; String[] str = fdbs.split(","); Set set = new TreeSet(); for (int i = 0; i < str.len...

java去掉字符串中重复的字符参考代码: //获取差集 public String getDifferenceSet(){ String ds = "";//差集字符串 boolean isDifference=false;//是否相同 //如果one的长度小于two的长度 就交换one和two if(one.length() < two.length()){ St...

import java.util.ArrayList;import java.util.List;public class $ { public static void main(String[] args) { String str = "教练教练裁判裁判裁判运动员运动员"; List data = new ArrayList(); for (int i = 0; i < str.length(); i++) { S...

String s="101,102,102,105,108,109,110,101";String[] array = s.split(",");StringBuilder sb = new StringBuilder();for (String str : array) {if(sb.indexOf(str) != -1){continue;}sb.append(str).append(",");}String newStr = sb.toStri...

举例: 1、String str = "abcdeabcdeabcdeaaaaaadddddceeeeabcccccccacadaeec"; str = str.replaceAll(reg, ""); System.out.println(str); 2、str = str.replaceAll("(?s)(.)(?=.*\\1)", ""); (?s)(.)(?=.*\1) 3、(?s) 开启单行模式 DOTALL 让....

public static void main(String[] args) { String str="r1qwerty"; String str1="qqwer1z"; String[] check = new test01().check(str,str1); System.out.println("str: "+check[0]); System.out.println("str1: "+check[1]); } public String[...

import java.util.*; class BaiDu { public static void main(String[] args) { TreeSet tr = new TreeSet(); String[] s ={"11","22","22","33","33","33"}; System.out.print("====处理前======="); for(int i=0;i

package test;public class StringHeBing { public static String merge(String str1,String str2){ int len = str2.length(); for (int i = 0; i < len; i++) { char c = str2.charAt(i); if (str1.indexOf(c) == -1) { str1 = str1.concat(c+"...

利用map public class DistinctObject { public static Map map = new HashMap(); public static void main(String[] args){ // 产生数组 StudentModel[] students = createStudents(); // 去掉重复元素 distinctStudents(students); for (Map.E...

网站首页 | 网站地图
All rights reserved Powered by www.wmjy.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com