воскресенье, 29 мая 2011 г.

непонимание3

What will be the output of the following code?

public class StrBld {
 
     public static void main(String[] args) {
         String str = new String("abc");
         StringBuilder stb = new StringBuilder(str);
 
         if (str.equals(stb.toString())) {
             System.out.println("true");
         } else {
             System.out.println("false");
         }
 
         if (str.equals(stb)) {
             System.out.println("true");
         } else {
             System.out.println("false");
         }
     }
 } 
The correct answer is:
true
false 

Комментариев нет: