这里只贴出主要运行的main方法, 大家自行创建包,类
public
static
void
main(String[] args) {
String text1 = "ge1,ge2,ge3,ge4,ge5";
String text2 = "ge1,ge4,ge3,ge5";
StringBuilder sb = new StringBuilder();
String[] strings = text1.split(",");
for (String s : strings) {
if (!text2.contains(s)) {
sb.append(s + ",");
}
}
String c = sb.substring(0, sb.length()).toString();
System.out.println("text1文本中text2没有的元素是:"+c);
}