



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
An introduction to java packages, their purpose, and the process of creating and importing them. Learn about package name conventions, fully qualified names, and access specifiers for class members. Understand how packages help manage unique class names, application complexity, and application organization.
Typology: Slides
1 / 7
This page cannot be seen from the preview
Don't miss anything!
An Introduction
Java Short Course Example
Unique class names Application management Complexity handling
package (keyword) package name Should be the first statement in source file
Initial part: Internet domain name in reverse order (sun specification) Last part: Any name that reflect the classes in package
Com.sun.2Dgraphics
Package name becomes part of class identity A class name when written with its package name is termed as its fully qualified name Example my2Dgraphics.Circle bscis.semester0.xyz.Circle Directory structure reflected by two class files will be outputpath/my2Dgraphics/Circle.class Outputpath/bscis/semester0/xyz/Circls.class
Import statement should placed before start of a class Example import javax.swings.JOptionPane; Import javax.swings.*;
Declaration Body
Access Specifier : public private protected Class name Super class name (parent class ) Interface (yet to discuss) Keywords : class extends implements Examples: class Box [ just class name and class keyword] public class Box [access specifier added ] Public class Box extends Rectangle [ example of inheritance] Public class Box implements printable [ interface usage]
The keyword protected is written to make a member protected A protected member is accessible to other classes with in the package Outside the package only child classes can access a protected member Not accessible to non-inherited classes outside the package
When no access specifieris used before a class member the access of that member function or variable is default or package Such members are accessible to other classes within the package Such members are not accessible to other classes outside the package