To use a class or a package from the library, you need to use the import keyword:
|
|
If you find a class you want to use, for example, the ArrayList class, which is used to get user input, write the code:
|
|
java.util
is a package, while ArrayList
is a class of the java
.util
package.
To use the ArrayList
class, create an object of the class and use any of the available methods found in the ArrayList
class documentation.
The following example will use the add()
method, which appends the specified element to the end of this list, and check whether the last parameter is in the previous parameters: