3.1 演示字符串操作的应用程序

 1 //Demonstrating some String methods.
 2 public class StringDemo
 3 {
 4     public static void main(String args [])
 5     {
 6         String strOb1 = "First String";
 7         String strOb2 = "Second String";
 8         String StrOb3 = strOb1;
 9         System.out.println("Length of strOb1:" +strOb1.length ());
10         System.out.println("Char at index 3 in strOb1:" +strOb1.charAt (3));
11         if(strOb1.equals(strOb2))
12             System.out.println("strOb1 == strOb2");
13         else
14             System.out.println("strOb1 ! = strOb2");
15         if (strOb1.equals(strOb3))
16             System.out.println("strOb1 == strOb3");
17         else
18             System.out.println("strOb1 != strOb3");
19     }
20 }
View Code

运行出错,回头检查

Compilation Failed
/usercode/file.java:15: error: cannot find symbol
  if (strOb1.equals(strOb3))
                    ^
  symbol:   variable strOb3
  location: class file
1 error

posted on 2019-03-12 23:11  空谈误国-实干兴邦  阅读(147)  评论(0编辑  收藏  举报