Java??????????????????
???????????? ???????[ 2015/4/22 11:51:40 ] ????????Java ?????? 10??????
?????????г???Java??????????????????
????1.??????????ArrayList
????????????????ArrayList?????????????????????
????List<String> list = Arrays.asList(arr);
????Arrays.asList()???????ArrayList???????ArrayList??Arrays????о????????java.util.ArrayList??java.util.Arrays.ArrayList??set()?? get()?? contains()????????????κ?????????????????????????С????????
???????????????????ArrayList?????????????
????ArrayList<String> arrayList = new ArrayList<String>(Arrays.asList(arr));
????ArrayList?????????????????Collection????????????java.util.Arrays.ArrayList???????????
????2.????????????????????
?????????????????????
????Set<String> set = new HashSet<String>(Arrays.asList(arr));
????return set.contains(targetValue);
?????????????????????????????????????????????????????????????????????????????????
????Arrays.asList(arr).contains(targetValue);
????????
????for(String s: arr){
????if(s.equals(targetValue))
????return true;
????}
????return false;
???????????????????????á?
????3.????????????б?????
??????????????????????????????????
????ArrayList<String> list = new ArrayList<String>(Arrays.asList("a"?? "b"?? "c"?? "d"));
????for (int i = 0; i < list.size(); i++) {
????list.remove(i);
????}
????System.out.println(list);
??????????£?
????[b?? d]
?????????????????????????????????????????б???С??С???????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????Java??foreach????????????????????????????????????????
????ArrayList<String> list = new ArrayList<String>(Arrays.asList("a"?? "b"?? "c"?? "d"));
????for (String s : list) {
????if (s.equals("a"))
????list.remove(s);
????}
???????????????ConcurrentModificationException??
???????????????????
????ArrayList<String> list = new ArrayList<String>(Arrays.asList("a"?? "b"?? "c"?? "d"));
????Iterator<String> iter = list.iterator();
????while (iter.hasNext()) {
????String s = iter.next();
????if (s.equals("a")) {
????iter.remove();
????}
????}
????.next()?????????????.remove()?????????á???foreach????????????????????.remove()???????.next()???????????ConcurrentModificationException????????????ArrayList.iterator()???????
????4.HashTable vs HashMap
?????????????????HashTable?????????????????????Java????HashMap?????????????????Hashtable?? HashMap????????????????HashTable??????????HashMap?????????????????HashTable??HashMap??????
????HashMap vs. TreeMap vs. Hashtable vs. LinkedHashMap
????Top 9 questions about Java Maps
????5.?????????????
??????Java????????????????????????????????????Set?????Set??????????????Set< ? >?????????????????
?????????????????????List????????????
????public static void add(List list?? Object o){
????list.add(o);
????}
????public static void main(String[] args){
????List<String> list = new ArrayList<String>();
????add(list?? 10);
????String s = list.get(0);
????}
?????????????????????
????Exception in thread "main" java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String at ...
????????????????????Σ???????????????????????????????飬?????????Set??Set< ? >??Set< Object >????к??????ο?Raw type vs. Unbounded wildcard??Type Erasure??
????6.???????
????????????????Public?????????η????????????????????????????????????????????????????????飬??????????????????????????
????public?? default?? protected?? and private
????7.ArrayList vs LinkedList
????????????????ArrayList??LinkedList??????????????????ArrayList?????????????????????????????????к?? ???????????????????д????????/???????????????????????????????????????LinkedList???????????????ο?ArrayList vs. LinkedList??
????8.????????
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???????????£???????????????????????????м??????????????????????????????????????ò??????????????????????????????????????????????????CPU????????????????????????????(????StringBuilder)??
????String result="";
????for(String s: arr){
????result = result + s;
????}
?????????????Щ????????????????????????罫???????????????????????????????ú????????????????????????????????????? ???????????????д?????????????????????????????????????????????????????????????????(????StackOverFlow??dasblinkenlight???????
????Why String is Immutable?
????9.???????????????
?????????ж??常????????????????????????????????Java??????????????ж??幹????????????????????????????????????????????????????????????????????????м?Super(String s)??????????????????????????????????????????????и???????Ρ?
????????????????????????в????????в??????????????????ι?????????????????????super()????????????????????С?????????????????δ???壬??????????????????????
?????????????????????????1)?????????????Super()????????????????
????public Super(){
????System.out.println("Super");
????}
????????2)??????????????????????3)?????????????е???????super(value)??
????Constructor of Super and Sub
????10.”“???????????
???????????????????????
????//1. ?????????
????String x = "abc";
????//2. ???ù?????
????String y = new String("abc");
?????????????
??????????????????????????????
????String a = "abcd";
????String b = "abcd";
????System.out.println(a == b); // True
????System.out.println(a.equals(b)); // True
????String c = new String("abcd");
????String d = new String("abcd");
????System.out.println(c == d); // False
????System.out.println(c.equals(d)); // True
????????????????????????????ο?Create Java String Using ”” or Constructor?
?????????????
????????б?????????????GitHub??????????Stack Overflow?????????Щ??????Google??????????????????????????????????????10??????????????????????????????????? ?????????????????????????????????Щ?????????????????м???
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11