两个字符串看起来相同但不相等

时间:2018-11-28 07:18:20

标签: java

我具有相同的列表,内部和外部评论列表的两个列表内容看起来都相同,但无法正常工作。请参阅下面的示例。

List<String> internalComment = Arrays.asList(
    "[~abhijit.karanjkar] [~aiyer][~pdewan]How can we test this if the LDAP configuration is set to false? Is it necessary this be set to false? If so why? Is there a workaround for testing?nnCurrently this would fail any meta plkayak tests in automation as well as manual test performed by webomates or in-house specific testing.");
List<String> externalComment = Arrays.asList(
    "[~abhijit.karanjkar] [~aiyer][~pdewan]How can we test this if the LDAP configuration is set to false? Is it necessary this be set to false? If so why? Is there a workaround for testing?nnCurrently this would fail any meta plkayak tests in automation as well as manual test performed by webomates or in-house specific testing.");

Set<String> newComment = new HashSet<>();
externalComment.forEach(extComm -> {
    if (!internalComment.contains(extComm)) {
        newComment.add(extComm);
    }
});

当我调试并发现添加了一个额外的空间时,我突出显示如下: 为什么添加一个额外的空间以及如何删除它?

内部评论

[[,〜,a,b,h,i,j,i,t,。,k,a,r,a,n,j,k,a,r,],,[,〜,a ,i,y,e,r, ],[, 〜,p,d,e,w,a,n,],H,o,w, c,a,n,,w,e,,t,e,s,t,,t,h,i,s,,i,f,,t,h,e,,L,D,A,P, ,c,o,n,f,i,g,u,r,a,t,i,o,n,,i,s,,s,e,t,,t,o,,f,a,l ,s,e,?,I,s,,i,t,,n,e,c,e,s,s,a,r,y,,t,h,i,s,,b,e, ,s,e,t,,t,o,,f,a,l,s,e,?,,I,f,,s,o,,w,h,y,?,,I,s,, t,h,e,r,e,,a,,w,o,r,k,a,r,o,u,n,d,,f,o,r,,t,e,s,t, i,n,g,?,n,n,C,u,r,r,e,n,t,l,y,,t,h,i,s,,w,o,u,l,d, ,f,a,i,l,,a,n,y,,m,e,t,a,,p,l,k,a,y,a,k,,t,e,s,t,s ,,i,n,,a,u,t,o,m,a,t,i,o,n,,a,s,,w,e,l,l,,a,s,,m,a ,n,u,a,l,,t,e,s,t,,p,e,r,f,o,r,m,e,d,,b,y,,w,e,b,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