StringBuilder .equals Java

后端 未结 8 1903
谎友^
谎友^ 2020-12-08 20:09
class strb
{

    static public void main(String...string)
    {
         StringBuilder s1 = new StringBuilder(\"Test\");
         StringBuilder s2 = new StringBuild         


        
8条回答
  •  一生所求
    2020-12-08 20:31

    Agreed with both of the above responses, but I'm worth noting to actually compare contents you can do:

    System.out.println(s1.toString().equals(s2.toString())); //Line 1
    

提交回复
热议问题