今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Generic typing
- [Instructor] Let's walk through some examples that demonstrate the benefit of using generics with collections. Collections can work with any type of object. So the same type of collection that we use to store strings can also be used to store custom objects like our room. It's not like we need a separate type of collection for the string and another for the room. Like we see in the example, we can use an array list to hold both types. Now collections are only meant to work with objects. So if we insert a primitive like this long, it needs to be autoboxed to its wrapper type to work with the collection. We can see this in action if we stream our collection and then print out the type of its elements. Here I'm just going to get the class of each element in our collection within the stream and print them out. Let's see what happens. You'll notice that our primitive long was autoboxed to its wrapper type java.lang.long.…
内容
-
-
-
-
Interfaces6 分钟 58 秒
-
(已锁定)
Collection types2 分钟 52 秒
-
(已锁定)
The Collection interface2 分钟 4 秒
-
Collection methods4 分钟 24 秒
-
(已锁定)
Creating a collection5 分钟 4 秒
-
(已锁定)
Generic typing4 分钟 26 秒
-
(已锁定)
Object comparison2 分钟 19 秒
-
(已锁定)
The equals method6 分钟 40 秒
-
(已锁定)
Challenge: Adding and removing collection elements5 分钟 6 秒
-
(已锁定)
Challenge: Advanced collection problems6 分钟 48 秒
-
-
-
-
-
-
-
-