Skip to content

Commit 7a9b59a

Browse files
committed
增加目录
1 parent ddeb7a7 commit 7a9b59a

File tree

3 files changed

+414
-2
lines changed

3 files changed

+414
-2
lines changed

contents/create-arraylist-arraylistt-from-array-t.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,24 @@
55
```java
66
Element[] array = {new Element(1),new Element(2),new Element(3)};
77
```
8-
如何将其转换为ArrayList`<Element>` arraylist呢?
8+
如何将其转换为ArrayList`<Element>` arraylist = ???
9+
10+
### 回答1 ###
11+
12+
`new ArrayList<Element>(Arrays.asList(array))`
13+
14+
###回答2
915

10-
###回答
1116
Arrays.asList(array)或者Arrays.asList(new Element(1),new Element(2),new Element(3))
1217

1318
不过,这样做有些坑要注意:
1419

1520
1. 这样做生成的list,是定长的。也就是说,如果你对它做add或者remove,都会抛UnsupportedOperationException。
1621
2. 如果修改数组的值,list中的对应值也会改变!
1722

23+
**Arrays.asList() 返回的是Arrays内部静态类,而不是Java.util.ArrayList的类。这个java.util.Arrays.ArrayList有set(),get(),contains()方法,但是没有任何add() 方法,所以它是固定大小的**
24+
25+
1826
如果希望避免这两个坑,请改用这个方式
1927
```java
2028
Collections.addAll(arraylist, array);

contents/目录.md

+202
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
# [目录](http://stackoverflow.com/questions/tagged/java?page=1&sort=votes&pagesize=15) #
2+
3+
## [1、为什么处理排序过得数组比没有排序的数组快](http://stackoverflow.com/questions/11227809/why-is-processing-a-sorted-array-faster-than-an-unsorted-array "Why is processing a sorted array faster than an unsorted array?") ##
4+
5+
6+
## [2、为什么在1927年的两个时间相减会产生奇怪的结果](http://stackoverflow.com/questions/6841333/why-is-subtracting-these-two-times-in-1927-giving-a-strange-result) ##
7+
8+
## [3、Java是传引用还是传值](http://stackoverflow.com/questions/40480/is-java-pass-by-reference-or-pass-by-value) ##
9+
10+
## [4、Java += 操作符](http://stackoverflow.com/questions/8710619/java-operator) ##
11+
12+
## [5、避免!=null 声明](http://stackoverflow.com/questions/271526/avoiding-null-statements) ##
13+
14+
## [6、Android适当的用例UserManager.isUserAGoat()](http://stackoverflow.com/questions/13375357/proper-use-cases-for-android-usermanager-isuseragoat) ##
15+
16+
## [7、HashMap和HaspTable的区别](http://stackoverflow.com/questions/40471/differences-between-hashmap-and-hashtable) ##
17+
18+
## [8、InputStream转换为String](http://stackoverflow.com/questions/309424/read-convert-an-inputstream-to-a-string) ##
19+
20+
## [9、为什么在存密码时char[]要优于String](http://stackoverflow.com/questions/8881291/why-is-char-preferred-over-string-for-passwords-in-java) ##
21+
22+
## [10、遍历HashMap](http://stackoverflow.com/questions/1066589/iterate-through-a-hashmap) ##
23+
24+
## [11、用数组创建一个ArrayList](http://stackoverflow.com/questions/157944/create-arraylist-from-array) ##
25+
26+
## [12、产生特定范围的随机数](http://stackoverflow.com/questions/363681/generating-random-integers-in-a-specific-range) ##
27+
28+
## [13、创建内存泄露?](http://stackoverflow.com/questions/6470651/creating-a-memory-leak-with-java) ##
29+
30+
## [14、LinkedList和ArrayList区别](http://stackoverflow.com/questions/322715/when-to-use-linkedlist-over-arraylist) ##
31+
32+
## [15、为什么动态的答应B比答应#慢](http://stackoverflow.com/questions/21947452/why-is-printing-b-dramatically-slower-than-printing) ##
33+
34+
## [16、serialVersionUID是什么](http://stackoverflow.com/questions/285793/what-is-a-serialversionuid-and-why-should-i-use-it) ##
35+
36+
## [17、把字符串转换为Int](http://stackoverflow.com/questions/5585779/converting-string-to-int-in-java) ##
37+
38+
## [18、public、default、protected、private的区别](http://stackoverflow.com/questions/215497/difference-between-public-default-protected-and-private) ##
39+
40+
## [19、Android设备是否有唯一的ID](http://stackoverflow.com/questions/2785485/is-there-a-unique-android-device-id) ##
41+
42+
## [20、怎么样测试私有方法,字段和内部类](http://stackoverflow.com/questions/34571/how-to-test-a-class-that-has-private-methods-fields-or-inner-classes) ##
43+
44+
## [21、怎样有效的遍历Map中的entry](http://stackoverflow.com/questions/46898/how-to-efficiently-iterate-over-each-entry-in-a-map) ##
45+
46+
## [22、使用java.net.URLConnection处理HTTP requests](http://stackoverflow.com/questions/2793150/using-java-net-urlconnection-to-fire-and-handle-http-requests) ##
47+
48+
## [23、为什么这段代码使用随机字符串答应"hello world"](http://stackoverflow.com/questions/15182496/why-does-this-code-using-random-strings-print-hello-world) ##
49+
50+
## [24、 如果使用Maven创建外部JAR](http://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven) ##
51+
52+
## [25、怎样判断数组包含一个特定的值](http://stackoverflow.com/questions/1128723/how-can-i-test-if-an-array-contains-a-certain-value) ##
53+
54+
## [26、如何在JSP中避免java代码](http://stackoverflow.com/questions/3177733/how-to-avoid-java-code-in-jsp-files) ##
55+
56+
## [27、一行代码初始化ArrayList](http://stackoverflow.com/questions/1005073/initialization-of-an-arraylist-in-one-line) ##
57+
58+
## [28、finally在java一定会被执行吗](http://stackoverflow.com/questions/65035/does-finally-always-execute-in-java) ##
59+
60+
## [29、"implements Runnable"和"extends Thread"](http://stackoverflow.com/questions/541487/implements-runnable-vs-extends-thread) ##
61+
62+
## [30、如何在一个构造函数中调用另一个](http://stackoverflow.com/questions/285177/how-do-i-call-one-constructor-from-another-in-java) ##
63+
64+
## [31、String转换为Enum](http://stackoverflow.com/questions/604424/convert-a-string-to-an-enum-in-java) ##
65+
66+
## [32、在//后代码会被执行](http://stackoverflow.com/questions/30727515/why-is-executing-java-code-in-comments-with-certain-unicode-characters-allowed) ##
67+
68+
## [33、处理java.lang.OutOfMemoryError:PermGen space错误](http://stackoverflow.com/questions/88235/dealing-with-java-lang-outofmemoryerror-permgen-space-error) ##
69+
70+
## [34、退出嵌套循环](http://stackoverflow.com/questions/886955/breaking-out-of-nested-loops-in-java) ##
71+
72+
## [35、Android SDK 安装后找不到JDK](http://stackoverflow.com/questions/4382178/android-sdk-installation-doesnt-find-jdk) ##
73+
74+
## [36、Java内部类和嵌套类](http://stackoverflow.com/questions/70324/java-inner-class-and-static-nested-class) ##
75+
76+
## [37、在导入项目后出现必须覆盖超类方法的错误](http://stackoverflow.com/questions/1678122/must-override-a-superclass-method-errors-after-importing-a-project-into-eclips) ##
77+
78+
## [38、错误Unsupported major.minor version 51.0 error](http://stackoverflow.com/questions/10382929/how-to-fix-unsupported-major-minor-version-51-0-error) ##
79+
80+
## [39、声明数组](http://stackoverflow.com/questions/1200621/declare-array-java) ##
81+
82+
## [40、反射的作用](http://stackoverflow.com/questions/37628/what-is-reflection-and-why-is-it-useful) ##
83+
84+
## [41、Map值排序](http://stackoverflow.com/questions/109383/sort-a-mapkey-value-by-values-java) ##
85+
86+
## [42、产生字母数字型随机数](http://stackoverflow.com/questions/41107/how-to-generate-a-random-alpha-numeric-string) ##
87+
88+
## [43、判断一个数的根号是整数](http://stackoverflow.com/questions/295579/fastest-way-to-determine-if-an-integers-square-root-is-an-integer) ##
89+
90+
## [44、用==或者equals()比较enum成员](http://stackoverflow.com/questions/1750435/comparing-java-enum-members-or-equals) ##
91+
92+
## [45、最简单的答应数组](http://stackoverflow.com/questions/409784/whats-the-simplest-way-to-print-a-java-array) ##
93+
94+
## [46、java是否支持默认参数值](http://stackoverflow.com/questions/997482/does-java-support-default-parameter-values) ##
95+
96+
## [47、接口和抽象类区别](http://stackoverflow.com/questions/1913098/what-is-the-difference-between-an-interface-and-abstract-class) ##
97+
98+
## [48、IntelliJ持久化行号](http://stackoverflow.com/questions/13751/how-can-i-permanently-have-line-numbers-in-intellij) ##
99+
100+
## [49、StringBuilder and StringBuffer](http://stackoverflow.com/questions/355089/stringbuilder-and-stringbuffer) ##
101+
102+
## [50、怎么连接两个数组](http://stackoverflow.com/questions/80476/how-can-i-concatenate-two-arrays-in-java) ##
103+
104+
## [51、在JUit中怎么断言异常](http://stackoverflow.com/questions/156503/how-do-you-assert-that-a-certain-exception-is-thrown-in-junit-4-tests) ##
105+
106+
## [52、字符串比较](http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java) ##
107+
108+
## [53、根据文件的内容创建字符串](http://stackoverflow.com/questions/326390/how-to-create-a-java-string-from-the-contents-of-a-file) ##
109+
110+
## [54、Failed to load the JNI shared Library (JDK)](http://stackoverflow.com/questions/7352493/failed-to-load-the-jni-shared-library-jdk) ##
111+
112+
## [55、JavaBean](http://stackoverflow.com/questions/3295496/what-is-a-javabean-exactly) ##
113+
114+
## [56、为什么我不能打开一个字符串](http://stackoverflow.com/questions/338206/why-cant-i-switch-on-a-string) ##
115+
116+
## [57、stack trace转换String](http://stackoverflow.com/questions/1149703/how-can-i-convert-a-stack-trace-to-a-string) ##
117+
118+
## [58、java核心代码的Gof设计模式例子](http://stackoverflow.com/questions/1673841/examples-of-gof-design-patterns-in-javas-core-libraries) ##
119+
120+
## [59、Apache Camel](http://stackoverflow.com/questions/8845186/what-exactly-is-apache-camel) ##
121+
122+
## [60、java为什么会有临时变量](http://stackoverflow.com/questions/910374/why-does-java-have-transient-variables) ##
123+
124+
## [61、Servlet 怎么工作](http://stackoverflow.com/questions/3106452/how-do-servlets-work-instantiation-shared-variables-and-multithreading) ##
125+
126+
## [62、重写equals和hashCode](http://stackoverflow.com/questions/27581/what-issues-should-be-considered-when-overriding-equals-and-hashcode-in-java) ##
127+
128+
## [63、得到当前stack trace](http://stackoverflow.com/questions/1069066/get-current-stack-trace-in-java) ##
129+
130+
## [64、foreach工作原理](http://stackoverflow.com/questions/85190/how-does-the-java-for-each-loop-work) ##
131+
132+
## [65、Access restriction on class due to restriction on required library rt.jar?](http://stackoverflow.com/questions/860187/access-restriction-on-class-due-to-restriction-on-required-library-rt-jar) ##
133+
134+
## [66、wait()和sleep()区别](http://stackoverflow.com/questions/1036754/difference-between-wait-and-sleep) ##
135+
136+
## [67、产生MD5hash](http://stackoverflow.com/questions/415953/how-can-i-generate-an-md5-hash) ##
137+
138+
## [68、在调用instanceof之前是否要检测is null](http://stackoverflow.com/questions/2950319/is-null-check-needed-before-calling-instanceof) ##
139+
140+
## [69、Download a file with Android, and showing the progress in a ProgressDialog](http://stackoverflow.com/questions/3028306/download-a-file-with-android-and-showing-the-progress-in-a-progressdialog) ##
141+
142+
## [70、初始化静态Map](http://stackoverflow.com/questions/507602/how-can-i-initialize-a-static-map) ##
143+
144+
## [71、怎么发现Android应用的内存只用量](http://stackoverflow.com/questions/2298208/how-do-i-discover-memory-usage-of-my-application-in-android) ##
145+
146+
## [72、在遍历list的时候,remove一个值,避免出现concurrenModificationExcetiion](http://stackoverflow.com/questions/223918/iterating-through-a-list-avoiding-concurrentmodificationexception-when-removing) ##
147+
148+
## [73、在java classpath中设置多行jars](http://stackoverflow.com/questions/219585/setting-multiple-jars-in-java-classpath) ##
149+
150+
## [74、Hibernate hbm2ddl.auto possible values and what they do](http://stackoverflow.com/questions/438146/hibernate-hbm2ddl-auto-possible-values-and-what-they-do) ##
151+
152+
## [75、split a String](http://stackoverflow.com/questions/3481828/how-to-split-a-string-in-java) ##
153+
154+
## [76、LINQ for java](http://stackoverflow.com/questions/1217228/what-is-the-java-equivalent-for-linq) ##
155+
156+
## [77、What's the difference between @Component, @Repository & @Service annotations in Spring](http://stackoverflow.com/questions/6827752/whats-the-difference-between-component-repository-service-annotations-in) ##
157+
158+
## [78、Can I add jars to maven 2 build classpath without installing them](http://stackoverflow.com/questions/364114/can-i-add-jars-to-maven-2-build-classpath-without-installing-them) ##
159+
160+
## [79、How to round a number to n decimal places in Java](http://stackoverflow.com/questions/153724/how-to-round-a-number-to-n-decimal-places-in-java) ##
161+
162+
## [80、对ArrayList的对象属性排序](http://stackoverflow.com/questions/2784514/sort-arraylist-of-custom-objects-by-property) ##
163+
164+
## [81、创建和写文件](http://stackoverflow.com/questions/2885173/how-to-create-a-file-and-write-to-a-file-in-java) ##
165+
166+
## [82、Update Eclipse with Android development tools v. 23](http://stackoverflow.com/questions/24437564/update-eclipse-with-android-development-tools-v-23) ##
167+
168+
## [83、Uncatchable ChuckNorrisException](http://stackoverflow.com/questions/13883166/uncatchable-chucknorrisexception) ##
169+
170+
## [84、怎么在一个整数的左边填充0](http://stackoverflow.com/questions/473282/how-can-i-pad-an-integers-with-zeros-on-the-left) ##
171+
172+
## [85、创建泛型数组](http://stackoverflow.com/questions/529085/how-to-create-a-generic-array-in-java) ##
173+
174+
## [86、判断三个以上为true条件](http://stackoverflow.com/questions/3076078/check-if-at-least-two-out-of-three-booleans-are-true) ##
175+
176+
## [87、ThreadLocal variable](http://stackoverflow.com/questions/817856/when-and-how-should-i-use-a-threadlocal-variable) ##
177+
178+
## [88、JSF、Servlet、JSP区别](http://stackoverflow.com/questions/2095397/what-is-the-difference-between-jsf-servlet-and-jsp) ##
179+
180+
## [89、为什么java向量类被认为是过时的和被废弃](http://stackoverflow.com/questions/1386275/why-is-java-vector-class-considered-obsolete-or-deprecated) ##
181+
182+
## [90、反编译DEX为源码](http://stackoverflow.com/questions/1249973/decompiling-dex-into-java-sourcecode) ##
183+
184+
## [91、ArrayList<String>转换为String[]数组](http://stackoverflow.com/questions/5374311/convert-arrayliststring-to-string-array) ##
185+
186+
## [92、软引用和弱引用的区别](http://stackoverflow.com/questions/299659/what-is-the-difference-between-a-soft-reference-and-a-weak-reference-in-java) ##
187+
188+
## [93、Efficiency of Java “Double Brace Initialization”](http://stackoverflow.com/questions/924285/efficiency-of-java-double-brace-initialization) ##
189+
190+
## [94、实现单例模式的最有效方法](http://stackoverflow.com/questions/70689/what-is-an-efficient-way-to-implement-a-singleton-pattern-in-java) ##
191+
192+
## [95、java中什么相当于C++的<L,R>](http://stackoverflow.com/questions/156275/what-is-the-equivalent-of-the-c-pairl-r-in-java) ##
193+
194+
## [96、从纯文本文件中读](http://stackoverflow.com/questions/4716503/reading-a-plain-text-file-in-java) ##
195+
196+
## [97、Which @NotNull Java annotation should I use](http://stackoverflow.com/questions/4963300/which-notnull-java-annotation-should-i-use) ##
197+
198+
## [98、为什么这段代码陷入无限循环](http://stackoverflow.com/questions/3831341/why-does-this-go-into-an-infinite-loop) ##
199+
200+
## [99、Eclipse: Set maximum line length for auto formatting](http://stackoverflow.com/questions/3697287/eclipse-set-maximum-line-length-for-auto-formatting) ##
201+
202+
## [100、Why does Math.round(0.49999999999999994) return 1](http://stackoverflow.com/questions/9902968/why-does-math-round0-49999999999999994-return-1) ##

0 commit comments

Comments
 (0)