2024年6月2日

摘要: 特点:代表一组任意类型的对象,无序、无下标、不能重复。 方法: 1.boolean add(Object obj)添加一个对象 2.boolean addAll(Collection c)将一个集合中的所有对象添加到此集合中。 3.void clear()清空此集合中的所有对象。 4.boolean 阅读全文
posted @ 2024-06-02 11:18 anonymity。 阅读(1) 评论(0) 推荐(0) 编辑

2024年5月29日

摘要: System系统类,主要用于获取系统的属性数据和其他操作,构造方法是私有的。 public class Demo01 { public static void main(String[] args) { //方法1.arraycopy:数组的复制 //1.src:源数组 //2.srcPos:从哪个 阅读全文
posted @ 2024-05-29 18:59 anonymity。 阅读(2) 评论(0) 推荐(0) 编辑
 
摘要: public class Demo01 { public static void main(String[] args) { //创建一个Calendar对象 Calendar calendar =Calendar.getInstance(); //打印目前时间 System.out.println 阅读全文
posted @ 2024-05-29 12:53 anonymity。 阅读(3) 评论(0) 推荐(0) 编辑

2024年5月28日

摘要: Date Date表示特定的瞬间,精确到毫秒。Date类中的大部分方法都已经被Calendar类中的方法所取代。 时间单位: 1秒=1000毫秒; 1毫秒=1000微秒; 1微秒=1000纳秒; 未过时的方法: 1.方法after before 2.比较 compareTo(); 3.比较是否相等 阅读全文
posted @ 2024-05-28 11:09 anonymity。 阅读(3) 评论(0) 推荐(0) 编辑

2024年5月27日

摘要: 位置:java.math包中 作用:精确计算浮点数 创建方式:BigDecimal bd=new BigDecimal("1.0"); 注意:使用的时候选择字符串 方法: BigDecimal add(BigDecimal bd) 加法 BigDecimal subtract(BigDecimal 阅读全文
posted @ 2024-05-27 20:03 anonymity。 阅读(2) 评论(0) 推荐(0) 编辑
 
摘要: StringBuffer:可变长字符串,jdk1.0提供,运行效率满、线程安全。 StringBuilder:可变长字符串,jdk5.0提供,运行效率快、线程不安全。(单线程推荐使用) 效率:StringBuilder>StringBuffer>String //验证StringBuilder效率高 阅读全文
posted @ 2024-05-27 17:42 anonymity。 阅读(1) 评论(0) 推荐(0) 编辑
 
摘要: substring方法:截取指定位置的字符串 public class Demo06 { public static void main(String[] args) { String str="this is a text"; //1.将str中的单词单独提取出来 String []arr= st 阅读全文
posted @ 2024-05-27 15:20 anonymity。 阅读(3) 评论(0) 推荐(0) 编辑
 
摘要: public String replace(char oldChar, char newChar ) 将旧字符串替换成新的字符串 public String[] split(String str) 根据str作拆分 代码详情: public class Demo05 { public static 阅读全文
posted @ 2024-05-27 09:36 anonymity。 阅读(2) 评论(0) 推荐(0) 编辑

2024年5月26日

摘要: public String trim() 去掉字符前后的空格 public String toUperCase() 将小写转成大写 public boolean endWith(String str) 判断字符串是否以str结尾 public static void main(String[] ar 阅读全文
posted @ 2024-05-26 10:29 anonymity。 阅读(2) 评论(0) 推荐(0) 编辑
 
摘要: public char[] toCharArray() 将字符串转换成数组。 pubulic int indexOf(String str) 查找str首次出现的下标,存在,则返回该下标;不存在,则返回-1。 public int last IndexOf(String str) 查找字符串在当前字 阅读全文
posted @ 2024-05-26 10:10 anonymity。 阅读(1) 评论(0) 推荐(0) 编辑