请阅读程序,然后写出程序运行结果。 public class Demo { public static void main(String args[]) { String s1 = new String("good"); String s2 = new String("GOOD"); String s3 = new String("good"); String s4 = "good"; boolean b1 = s1.equals(s2); boolean b2 = s1.equalsIgnoreCase(s3); boolean b3 = s2.endsWith("oD"); boolean b4 = (s1 == s4); System.out.println(b1); System.out.println(b2); System.out.println(b3); System.out.println(b4); } }
举一反三
- 以下程序的输出结果是 String s1="1",s2="2"; String s=s1+s2; System.out.println(s);
- public static void main(String[] args) { LinkedList list=new LinkedList(); list.add("A"); list.add("B"); String s=(String)list.get(2); System.out.println(s); } 编译运行的结果是
- 请说出下列代码的执行结果 : String s = "abcd"; String s1 = new String(s); if (s = = s1) System.out.println("the same"); if (s.equals(s1)) System.out.println("equals");
- 读代码:public class foo {static String s;public static void main (String[]args) {System.out.println (“s=” + s);}}结果是
- 以下代码共创建了几个对象?String s1=new String("hello");String s2=new String("hello");String s3=s1;String s4=s2; A: 2 B: 4 C: 1 D: 3