今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Creating a collection
- [Instructor] Let's walk through a few code examples that create a collection. Collections can be declared and instantiated like any other object. We specify the type of the collection, provide its identifier, and then instantiate a new collection implementation that will be assigned to the variable. I'm using the collection interface as the variable type. However, if I wanted to be more specific about the type, I could've switched over to use the set interface. So let's make the change and import the set from java.util.set. Now, the reason this works is because the hash set implements the set interface. We couldn't do something like using a list as our variable type because it's not compatible with hash set. But let's go ahead, we'll import the list from java.util.list, and then we'll change the implementation over to use the array list. So we'll add the array list constructor, and now we have a list. Now, let's…
内容
-
-
-
-
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 秒
-
-
-
-
-
-
-
-