Packages: ========= Ex: BankingAccount classes like: Account.java package1: customer.java Transaction.java package2: Payment.java What is Package? ================ Package is the collection of classes, interfaces and sub-packages ==> logically related classes are grouped together into one unit is called as "package". Why packages are used? ====================== 1) to organize the application 2) to avoid the name conflict How application with packages is organized? =========================================== Scenario:1: =========== Assume the package name : pack (package name always be in lower case only) under the package "pack" two classes like: ClassOne.java ClassTwo.java have added and one interface like: InterfaceOne.java package pack ClassOne.java ============= package pack; class ClassOne{ } ClassTwo.java ============== package pack; class ClassTwo{ } InterfaceOne.java ================== package pack; interface InterfaceOne{ } ==================================================== Scenario-2: =========== Assume the main package: "org" consisting of sub-package: "ashokit" includes: ClassA.java InterfaceA.java ClassA.java ============ package org.ashokit; class ClassA{ } InterfaceA.java =============== package org.ashokit; interface InterfaceA{ } ============================================================================ Scenario-3: =========== package com.ashokit.jdbc; class InsertTable{ } package com.ashokit.drop; class DropTable{ } ===================================== How name conflict can be reduced with packages? ================================================ Scenario: ========== Project : BankingSystem banking (main package) banking.savings (sub-package) transaction.java payment.java banking.current (sub-package) transaction.java payment.java Q: without inheritance, do we able to import the one class members into another class members within the same package?