码迷,mamicode.com
首页 > 编程语言 > 详细

字符串和数组

时间:2019-03-13 00:11:52      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:class   pil   har   ide   static   gif   cdb   led   hid   

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

字符串和数组

标签:class   pil   har   ide   static   gif   cdb   led   hid   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!