10 2013 档案
摘要:/*String类适用于描述字符串事物最常见的对字符串的操作1, 获取1 字符串中包含的字符个数,就是字符串的长度int length();获取长度2 根据位置获取某个位置上的字符char charAt(int index);3 根据字符获取该字符在字符串中的位置int indexOf(int ch);返回ch在字符串中第一次出现的位置int indexOf(int ch,int fromIndex);从fromIndex位置开始获取ch在字符串中第一次出现的位置int indexOf(String str);返回的是str在字符串中第一次出现的位置int indexOf(str str,in
阅读全文
摘要:class StringDemo {public static void main(String[] args) {String s1 = "abc";//s1 是一个类类型变量 “abc”是一个对象//字符串最大的特点是 一旦被初始化就不可能被改变String s2 = new String("abc");/*面试题 s1 和 s2 有什么区别s1, 在内存中有一个对象;s2, 在内存中有两个对象 new 是一个对象 “abc”也是一个对象*/System.out.println(s1==s2);//结果为falseSystem.out.println
阅读全文

浙公网安备 33010602011771号