java上机04Chapter.pptVIP

  • 5
  • 0
  • 约7.82千字
  • 约 46页
  • 2018-06-21 发布于福建
  • 举报
String类 String是最常用的一种Java引用类型 String类对象保存不可修改的Unicode字符序列 String常量是用双引号括起来的0到多个字符,例如:String s = HelloWorld; String类型数据可以和任何其它数据类型进行+操作,实现字符串连接的效果。 字符串举例 String message = “Hello World”; message = message + “!!”; StringBuffer messageBuf = new StringBuffer(message).append(“!!”); String str = messageBuf.toString(); 访问字符串 (1)获得字符串的长度 String a = the fat cat has a bag; int length= a.length(); (2)按照指定的索引下得到字符 String name = Martin; char c1= name.charAt(3); (3)从一个字符串或者字符串缓冲区得到多个字符 String s = the fat cat has a bag; String b = s. substring(8); String类常用方法

文档评论(0)

1亿VIP精品文档

相关文档