DESKTOP-QT2JO23_20200901-孙中霞
1、问题
我们考试的后的那个程序题有什么具体的算法和思路么???最后可以总结一下,发一个最优化的代码让我们借鉴借鉴么,我感觉我的代码太繁琐,但不知怎么优化!
2、
这个地方我每次都掉坑里,每次同桌考我,我就跳进坑里了
StringBuffer first = new StringBuffer( "abc" );
System.out.println( first + "【" + System.identityHashCode( first ) + "】" );
StringBuffer second = new StringBuffer( "abc" );
System.out.println( first + "【" + System.identityHashCode( second ) + "】" );
System.out.println( first == second ); // false
System.out.println( first.equals( second ) ); // false
3、解决
StringBuffer/StringBuilder都没有重写从Object继承的equals(Object)方法,equals比较时,只要是new 的它就不相等!
4、吐槽
还行,天气凉了点!
点赞