ImageVerifierCode 换一换
格式:DOCX , 页数:15 ,大小:19.17KB ,
资源ID:19811429      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/19811429.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Java常用系统类Word文档格式.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

Java常用系统类Word文档格式.docx

1、System.out.print(youscore=+score); (3)数据类型包装类基本类型对应包装类booleanBooleancharCharacterbyteByteshortShortintIntegerlongLongfloatFloatdoubleDoublepublic classE437 public static void main(String args )chara=a,bcDEF;for(int i=0;a.length;if(Character.isLowerCase(a) a=Character.toUpperCase(a);elseif(Character.

2、isUpperCase(a) a=Character.toLowerCase(a);+a);二、字符串(1)String类:创建不可变长的字符串 创建字符串String s1=“abc”;String s2=new String(“abc”); 比较两个字符串=和equals()方法。class TestEquals public static void main(String args)Strings1=abc;Strings2=String s3=newString(String s4=newString(System.out.println(s1=s2);System.out.print

3、ln(s2=s3);System.out.println(s3=s4);System.out.println(s1.equals(s2);System.out.println(s1.equals(s3); 字符串的其他常用方法length():字符串的长度,即字符串中字符的个数。concat(String str):字符串的连接。“+”:indexOf(int ch):在当前的字符串中查找字符ch,从前向后找。lastIndexOf(int ch): 在当前的字符串中查找字符ch,从后向前找。字符串的分析:StringTokenizer类。import java.util.*;public c

4、lass WordAnalyse StringTokenizer st=new StringTokenizer(helloeverybodywhile(st.hasMoreTokens()/判断是否有后续单词。 System.out.println(st.nextToken();/取下一个单词。public String split(Stringregex)方法:使用指定分隔符分离字符串。public class TestSplitString s=new String(boo:and:foofor(String s1:s.split(:)System.out.println(s1);(2)S

5、tringBuffer类:创建可变长的字符串 创建StringBuffer对象publicStringBuffer():创建一个空的StringBuffer对象。publicStringBuffer(int length):创建一个长度为length的StringBuffer对象。publicStringBuffer(String str):用字符串str初始化StringBuffer对象。 StringBuffer的主要方法classTestStringBufferpublic static void main(String args) StringBuffer str=newStringB

6、uffer(); str.append(Hello Mary! str.insert(6,good str.setCharAt(6,G str.deleteCharAt(15); str.replace(11,15,Tom System.out.println(str);(3)StringBuilder类(JDK5.0开始):StringBuilder不支持同步。StringBuffer支持同步。性能:StringBuilderStringBufferStringpublic classTestBfinal static int ttime=100000;/测试循环次数public TestB

7、()public void test(String s) long begin=System.currentTimeMillis(); for(int i=0;ttime;s+=add long over=System.currentTimeMillis(); System.out.println(操作+s.getClass().getName()+类型使用的时间为:+(over-begin)+毫秒public void test(StringBuffer s)s.append(public void test(StringBuilder s)public void test2() Strin

8、g s2=abadfString s=s2+s2+s2;操作字符串对象引用相加类型使用的时间为:public void test3()Strings=操作字符串相加使用的时间为: String s1=StringBuffer sb1=newStringBuffer(StringBuilder sb2=new StringBuilder(TestB t=new TestB();t.test(s1);t.test(sb1);t.test(sb2);t.test2();t.test3();三、Vector类Vector类实现了可扩展的对象数组。测试向量的大小及容量的变化。importjava.uti

9、l.*;public classTestCapacityVector v=new Vector();System.out.println(size=+v.size();capacity=+v.capacity();14;v.add(helloAfteradded 14 Elements(1)给向量序列尾部添加新元素(2)获取向量序列中元素(3)查找向量序列中元素(4)修改向量序列中元素(5)删除向量序列中元素(6)向量的遍历访问向量的添加、获取、修改、删除和遍历。public classTestVectorv.addElement(defxyzv(1)=+v.elementAt(1);+v.g

10、et(1);System.out.println(v);v.setElementAt(DEF,1);v.removeElementAt(1);v.size(); System.out.print(v.get(i)+ System.out.println();Iterator x=v.iterator();while(x.hasNext()System.out.print(x.next()+四、Collection API 简介在Java API中为了支持各种对象的存储访问提供了Collection(收集)系列API,Vector是这种类型的一种。(1)Collection接口及实现层次接口Co

11、llection处于Collection API的最高层次,其中定义了所有底层接口或类的公共方法,如下图所示:file:/C:/Users/SBT/AppData/Local/Temp/msohtmlclip1/09/clip_image001.gif Collection接口lboolean add(Object o):将一个对象加入到收集中。boolean contains(Object o):判断收集中是否包含指定对象。boolean isEmpty():判断收集是否为空。Iterator iterator():取得遍历访问收集的迭代子对象。boolean remove(Object o

12、):从收集中删除某对象。int size():获取对象的大小。Object toArray():将收集元素转化为对象数组。void clear():删除收集中所有的元素。 Set接口该接口是数学上集合模型的抽象,有两个特点:一是不含重复元素,而是无序。public class TestSetpublic staticvoid main(String args) HashSeth=new HashSet(); h.add(Str1 h.add(newInteger(12); h.add(newDouble(4.2); h.add(newString(); System.out.println(h

13、); List接口该接口类似于数学上数列的模型,也称序列。其特点是可含有重复元素,而且是有序的。类ArrayList内部使用基于动态数组的数据结构。类LinkedList内部使用基于链表的数据结构。对于随机访问get和set,ArrayList要优于LinkedList,因为linkedList要移动指针。对于新增和删除元素操作add和remove,LinkedList比较占优势,因为ArrayList要移动数据。 importjava.util.*;public class TestList publicstatic void main(String args)ArrayLista=new

14、ArrayList();a.add(a.add(newInteger(12);a.add(newDouble(4.2);a.add(newString(System.out.println(a);/或者使用迭代器访问a中的元素Iteratorp=a.iterator();while(p.hasNext() System.out.print(p.next()+,public class ListDemo2final int N=50000;long timeList(List st)long start=System.currentTimeMillis();for(inti=0;N;Object

15、 obj=new Integer(i);st.add(obj);longstop=System.currentTimeMillis();return(stop-start);ListDemo2l=new ListDemo2();timefor ArrayList=+l.timeList(new ArrayList();time forLinkedList=+l.timeList(new LinkedList();(2)Map接口及实现层次除了Collection表示的这种单一对象数据集合,对于“”表示的数据集合在CollectionAPI提供了Map接口。Map接口及其子接口的实现层次如下图:/Users/SBT/AppData/Local/Temp/msohtmlclip1/09/clip_image002.gifimport java.u

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1