Java两个字符串相减,用减法为什么不行,下面的程序错误在哪里

String s1 = "hellow word";
String s2 = "hellow ";
String s3 = s1 - s2; // s3希望得到 "word"
这个代码不行,那么正确写法是什么

直接使用字符串截取函数,费那劲呢,一个函数可以解决的问题尽量别敲代码,还有,是"hello world",不是"hello word",字符串截取函数:substring(begin,end);有两个,具体用法百度吧

没有相减的操作。只能通过判断是否包含来做到这种效果。代码如下:
String s1 = "hellow word";
String s2 = "hellow ";
String maxStr=s1.length()>s2.length()?s1:s2;
String minstr=s1.length()<=s2.length()?s1:s2;
int index =maxStr.indexOf(minstr);
if(index>=0)
System.out.println(maxStr.substring(0,index)+maxStr.substring(index+s2.length()));
若要是多个按照空格分隔。把它转换成List。就能用removeAll来实现。