User Tools

Site Tools


java_faq

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
java_faq [2016/09/22 11:40]
178.237.8.52 [ArrayList]
java_faq [2016/09/22 11:43]
178.237.8.52 [ArrayList]
Line 163: Line 163:
 ===== ArrayList ===== ===== ArrayList =====
  
-Arrays are unflexible in the way that they cannot be resized once created. When you need more flexibility in this respect you use an ArrayList. An ArrayList implements the [https://​docs.oracle.com/​javase/​8/​docs/​api/​java/​util/​List.html List] interface.+Arrays are unflexible in the way that they cannot be resized once created. When you need more flexibility in this respect you use an ArrayList. An ArrayList implements the [[https://​docs.oracle.com/​javase/​8/​docs/​api/​java/​util/​List.html ​List]] interface.
  
 A list is  A list is 
Line 270: Line 270:
  
 The output is kind of surprising: The output is kind of surprising:
- list1 [[I@15db9742] +  ​list1 [[I@15db9742] 
- list2 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]+  list2 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 
 + 
 +that means that ''​list1''​ is a list which contains an int[], while the other is what we expected to find. This has to do with [[https://​docs.oracle.com/​javase/​tutorial/​java/​generics/​types.html | Java generics]]. Java generics is the analogous of ''​templates''​ in C++, but while in C++ anything can be a ''​typename''​ in Java ''​a type variable can be any NON-PRIMITIVE type''​.
  
-that means that ''​list1''​ is a list which contains an int[], while the other is what we expected to find. This has to do with [[https://​docs.oracle.com/​javase/​tutorial/​java/​generics/​types.html ​ Java generics]]. Java generics is the analogous of ''​templates''​ in C++, but while in C++ anything can be a ''​typename''​ in Java ''​a type variable can be any NON-PRIMITIVE type''​. 
-[[http://​www.oracle.com/​technetwork/​java/​javase/​downloads/​jdk8-downloads-2133151.html | Oracle]] 
  
 In our example I used an array of primitives, which is the only object in the matter and Java used it to perform the transformation to List, as it is a non-primitive object. Therefore ''​list1''​ is a List containing one element of type ''​int[]''​. In our example I used an array of primitives, which is the only object in the matter and Java used it to perform the transformation to List, as it is a non-primitive object. Therefore ''​list1''​ is a List containing one element of type ''​int[]''​.
  
java_faq.txt · Last modified: 2017/01/02 14:01 by 178.237.8.52