- 博客(3)
- 收藏
- 关注
原创 foreach的用法
foreach遍历数组和集合 格式: for(元素类型 元素变量x:遍历对象(数组或集合)){ 引用元素变量x的语句; } 例: int[] array = new int[5]; for(int x : array){ System.out.println(x); } 遍历MAP集合格式如下: for (Map.Entry<K, V> entry : map.entrySet()) action.accept(entry.getKey(), entry.getValue());
2020-07-20 17:07:20
49217
2
原创 Java集合类的说明及些许例子
Java集合类 List , Set, Map都是接口,前两个继承至Collection接口,Map为独立接口。 Set下有HashSet,LinkedHashSet,TreeSet。 List下有ArrayList,Vector,LinkedList。 Map下有Hashtable,LinkedHashMap,HashMap,TreeMap。 Collection接口下还有个Queue接口,有PriorityQueue类。 List 接口:元素按进入先后有序保存,可重复 ArrayList 优点: 底层数
2020-07-20 14:55:13
203
原创 String和StringBuffer的常用方法及些许例子
String常用方法: charAt(int index): 获取指定索引处的字符。 indexOf(String str): 获取str在字符串对象中第一次出现的索引。 substring(int start): 从start开始截取字符串。 substring(int start,int end): 从start开始,到end结束截取字符串。包括start,不包括end。 toCharArray(): 把字符串转换为字符数组。 toLowerCase(): 把字符串转换为小写字符串。 toUpp
2020-07-20 14:53:18
240
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人