i
Understanding Requirement: Why Java
Why Java is important to the Internet
Java On Linux
First Java Program
Java Virtual Machine Architecture
Class Loading Process by Class Loaders
Role Of Just In Time Compiler
Execution Engine
Data Types
Variables
Arrays
Operators
Arithmetic Operations
Shifting Operators
Logical Operators
Control Statements
Object Oriented Paradigms
The Three OOP principles
Looping Statements
JAVA Class Fundamentals
Command Line Arguments
Static Initialize
Creating an Object
Instance Variable Hiding
Overriding and Overloading of methods
Understanding The Access Controls
Nested And Inner Classes
Dynamic Method Dispatching
Abstract Classes
Using Final To Prevent Overriding & Inheritance
Garbage Collection
Defining a package
Understanding Classpath
Access Protection
Importing packages
Defining and Implementing An Interface
Abstract classes vs Interfaces
Generics
Annotations
Varargs
Foreach
Fundamentals Of Exception Handling
Types Of Exceptions
Learning exception handling, try-catch, multiple catch clauses
Nested Try Statements
Throw, Throws and Finally
Custom Exceptions
Java Thread Model
Creating A Thread
Context Switching
Synchronization: Methods And Statements
Inter-thread Communication
As mentioned earlier, packages are just folders for Java classes, interfaces and so on. These packages help us to reserve the class namespace and create the code which will be easily maintainable. For instance, we can find two Date classes in Java. However, the recommendation in Java programming is that, only one unique class name is allowed in a Java project.
How did they manage to put two classes with the identical name in JDK?
This was doable because these two Date classes belong to different packages:
java.util.Date – this is an usual Date class that can be used anywhere.
java.sql.Date – this is a SQL Date which is used only in SQL query and such.
Built-in packages such as: java.lang, java.util, java.io etc. are java packages that come along with the JDK.
In order to import entire package in our Java file, we can use import statement with asterisk sign (as in earlier examples), or use only certain classes and interfaces defined in the package.
The general form of import statement is:
The import statement is optional in Java. If we want to use class/interface from a certain package, we can also use it with fully qualified name, which includes its full package hierarchy. Below is an example to import package with import statement.
Don't miss out!