首页 > 编程语言 > 详细

字符串和数组

时间:2019-03-12 23:33:29      阅读:214      评论:0      收藏:0      [点我收藏+]

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

字符串和数组

原文:https://www.cnblogs.com/allison-aichipingguo/p/10520326.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!