Professional Documents
Culture Documents
ADVANCED PROGRAMMING
(Lecture Note 3: Packages, Abstract Class, Interface, Inner class & Exception
Handling)
By
Isma’il Aliyu
Department of Mathematical Sciences
ATBU, Bauchi.
2020/2021 Session
Package
• Java allows you to group classes in a collection called a
package.
– A package in Java is name giving to a folder or directory for
keeping source files.
• Packages are convenient for organizing your work and for
separating your work from code libraries provided by
others. The main reason for using packages is to guarantee
the uniqueness of class names.
• The standard Java library is distributed over a number of
packages; such as java.lang, java.util, java.net, and so on.
• The standard Java packages are examples of hierarchical
packages. Just as you have nested subdirectories on your
hard disk
class OuterClass {
... class InnerClass {
... }
}
try{ try{
// exception prone code // exception prone code
}catch(ExceptionName e){ }catch(ExceptionName1 e1){
// catch block // catch block1
} } catch(ExceptionName2 e2){
// catch block2
• A try block can be followed } catch(ExceptionNameN eN){
by multiple catch blocks // catch blockN
• See the next example. }