Packages in Java allow classes to be grouped together logically and prevent naming collisions. The key Java packages are:
1) java.lang contains classes for primitive types, strings, math functions, and exceptions.
2) java.util contains utility classes like vectors and hash tables.
3) java.io contains stream classes for input/output.
Packages are organized hierarchically, for example the awt package contains classes for graphical user interfaces. Classes in packages can be accessed using their fully qualified name or by importing the package. Users can also create their own packages by specifying the package name at the top of Java files in a corresponding directory structure.
The document discusses Java packages. The key points are:
- Packages are containers that group related classes and interfaces together. They allow for organizing code and uniquely naming classes.
- The core Java packages are java.lang, java.util, java.io, java.awt, java.net, and java.applet. They contain fundamental classes for various purposes.
- To use classes from a package, the package must be imported or the fully qualified class name can be used. The package statement declares user-defined packages.
Packages in Java allow for organizing related classes and interfaces. There are built-in packages like java, lang, and util, as well as user-defined packages. Packages can be organized hierarchically with multiple levels separated by periods. The package statement specifies the package, and classes within a package must be referred to using their fully qualified name unless imported. Packages and classes provide different levels of access protection for their members. The import statement allows classes from other packages to be referred to by their simple names.
This document discusses packages in Java. It defines packages as containers for grouping related classes and interfaces. There are built-in packages provided by Java, such as java.lang for core classes and java.util for utility classes. Users can also create their own packages by specifying the package name at the top of a file and storing the class files in a subdirectory matching the package name. Packages provide advantages like organizing related classes, hiding classes to prevent accidental deletion, and allowing class name reuse across packages.
This presentation introduces Java packages, including system packages that are part of the Java API and user-defined packages. It discusses how packages organize related classes and interfaces, the structure of package names and directories, and how to create and access packages. Packages provide advantages like grouping related code, preventing name collisions, and improving reusability.
Packages in Java provide a mechanism for organizing classes and interfaces by grouping related ones together. Packages can control visibility and access to classes. The package statement specifies the package a class belongs to, and packages are mapped to directories in the file system. Interfaces in Java specify a contract that classes can implement, defining method signatures but not bodies. This allows for abstraction and polymorphism.
A package in Java is a grouping of related classes and interfaces that provides namespacing to avoid naming conflicts. There are two types of packages: predefined packages provided by Java and user-defined packages. Packages provide advantages like reusability and better organization. Some key predefined packages include java.lang, java.io, java.util, java.applet, and java.awt. To define a user package, include the package statement as the first line in a Java source file, which specifies the package name. Classes in that file will belong to that package.
This document discusses packages in Java. It defines a package as a mechanism to encapsulate a group of classes, subpackages, and interfaces. Packages are used to prevent naming conflicts, make classes and interfaces easier to locate and use, and provide access control. Package names are related to directory structure, and packages can be considered a form of data encapsulation. The document also discusses built-in packages that are part of the Java API, as well as how to define and use user-defined packages through directory structure and import statements.
This document discusses packages in Java. It defines a package as a mechanism to encapsulate a group of classes, subpackages, and interfaces. Packages are used to prevent naming conflicts, make classes and interfaces easier to locate and use, and provide access control. Package names are related to directory structure, and packages can be considered a form of data encapsulation. The document also discusses built-in packages that are part of the Java API, as well as how to define and use user-defined packages through directory structure and import statements.
This document presents information about Java packages. It introduces the topic of packages and discusses how to create, use, import and access packages and package members. The document provides examples to illustrate key concepts such as defining a package, matching package names to directory structures, importing packages and accessing classes from other packages. It also outlines some benefits of using packages such as avoiding name conflicts and restricting access. The presentation was delivered by group members with IDs ranging from 131-15-2223 to 131-15-2421.
This document discusses Java packages. It explains that packages allow for organizing classes into namespaces to achieve code reuse and prevent naming collisions. Packages act as containers that group related classes and interfaces. The document also provides details on using packages from the Java API, package access protection, creating JAR files, package naming conventions, and common mistakes when working with packages.
This document summarizes key concepts about packages, classes, and the static keyword in Java. It discusses how packages are used to organize classes and prevent naming conflicts. It also explains that the static keyword in Java is used for memory management and that static variables, methods, blocks, and nested classes belong to the class rather than object instances. The document provides examples of how to define packages and use the static keyword with variables, methods, and blocks in Java programs.
- A package is used to organize related classes and interfaces by grouping them into directories based on functionality and category.
- Packages provide access protection and prevent naming conflicts. Classes within a package can access each other but restrict access from other packages.
- To create a package, a corresponding directory structure must be made that matches the package name hierarchy. Classes are added to a package by including the package statement at the top of the class file.
Packages in Java allow grouping of related classes and avoid naming collisions. A package is mapped to a directory on the file system where Java files for that package are stored. There are predefined packages provided by Java and user-defined packages can also be created. Packages are specified using the package keyword and imported into other classes using import statements. The classpath variable is used to locate packages and classes for compilation and execution.
Packages in Java allow grouping of related classes and interfaces to avoid naming collisions. Some key points about packages include:
- Packages allow for code reusability and easy location of files. The Java API uses packages to organize core classes.
- Custom packages can be created by specifying the package name at the beginning of a Java file. The class files are then compiled to the corresponding directory structure.
- The import statement and fully qualified names can be used to access classes from other packages. The classpath variable specifies locations of package directories and classes.
This document discusses Java programming packages. It explains that Java API provides predefined packages organized by functionality. Packages are hierarchical, so classes can be accessed using package names and dot notation. The import statement allows accessing package classes without fully qualifying names. To create a package, the package keyword declares the name, then classes within that package are defined and stored in a subdirectory matching the package name. Packages can be accessed using import or fully qualifying class names with the package path.
Packages in Java are used to categorize classes and interfaces to facilitate organization and access protection. There are two types of packages - built-in packages that are part of the Java API, and user-defined packages that are created by the user. Classes can be imported into other packages using either "import package.*" to access all classes, "import package.classname" to access a specific class, or the fully qualified name. This allows code reuse through organizing related classes and controlling access.
This document discusses Java packages. It defines packages as groups of related classes and interfaces, and notes there are two types: system packages from the Java API and user-defined packages. It explains how to create a user-defined package by declaring the package name at the top of a file, making classes within it public, compiling the file, and importing the package. An example is provided to demonstrate creating a package with two classes and using them in a main method after importing the package.
Packages allow for organizing related classes and interfaces into namespaces to avoid naming conflicts. A package is defined using the package keyword and places class files into a directory structure that matches the package name. The classpath specifies the locations where the JVM will search for class files and external library files needed at runtime. It can be set using the -classpath option or CLASSPATH environment variable and allows packages to be accessed across directories and archives.
This document discusses packages and interfaces in Java. It defines a package as a container for classes that organizes the class namespace. Packages can be built-in or user-defined. Interfaces define method signatures but do not provide implementations. Classes can implement interfaces. The key differences between classes and interfaces are that interfaces contain only abstract methods while classes can contain concrete methods, and multiple inheritance is only possible with interfaces.
Tahmid Mobashir presented on Java packages. Packages are collections of related classes and interfaces that provide namespace management and access protection. Packages can contain subpackages and types declared in compilation units. Packages make classes easier to find, avoid naming conflicts, and control access. To create a package, a package statement with the package name is included at the top of source files containing the classes and interfaces for that package. The files are then compiled using the javac command with the -d option to place the class files in a folder matching the package name.
This document discusses Java packages and JAR archives. It explains that packages are used to organize related classes and avoid naming collisions. Classes are organized into a directory structure that matches their package hierarchy. The classpath is used to locate classes and JAR files can be used to distribute applications and resources. The document provides examples of how to declare packages, import classes, and access resources within JAR files.
This document discusses packages in Java. It defines a package as a mechanism to encapsulate a group of classes, subpackages, and interfaces. Packages are used to prevent naming conflicts, make classes and interfaces easier to locate and use, and provide access control. Package names are related to directory structure, and packages can be considered a form of data encapsulation. The document also discusses built-in packages that are part of the Java API, as well as how to define and use user-defined packages through directory structure and import statements.
This document discusses packages in Java. It defines a package as a mechanism to encapsulate a group of classes, subpackages, and interfaces. Packages are used to prevent naming conflicts, make classes and interfaces easier to locate and use, and provide access control. Package names are related to directory structure, and packages can be considered a form of data encapsulation. The document also discusses built-in packages that are part of the Java API, as well as how to define and use user-defined packages through directory structure and import statements.
This document presents information about Java packages. It introduces the topic of packages and discusses how to create, use, import and access packages and package members. The document provides examples to illustrate key concepts such as defining a package, matching package names to directory structures, importing packages and accessing classes from other packages. It also outlines some benefits of using packages such as avoiding name conflicts and restricting access. The presentation was delivered by group members with IDs ranging from 131-15-2223 to 131-15-2421.
This document discusses Java packages. It explains that packages allow for organizing classes into namespaces to achieve code reuse and prevent naming collisions. Packages act as containers that group related classes and interfaces. The document also provides details on using packages from the Java API, package access protection, creating JAR files, package naming conventions, and common mistakes when working with packages.
This document summarizes key concepts about packages, classes, and the static keyword in Java. It discusses how packages are used to organize classes and prevent naming conflicts. It also explains that the static keyword in Java is used for memory management and that static variables, methods, blocks, and nested classes belong to the class rather than object instances. The document provides examples of how to define packages and use the static keyword with variables, methods, and blocks in Java programs.
- A package is used to organize related classes and interfaces by grouping them into directories based on functionality and category.
- Packages provide access protection and prevent naming conflicts. Classes within a package can access each other but restrict access from other packages.
- To create a package, a corresponding directory structure must be made that matches the package name hierarchy. Classes are added to a package by including the package statement at the top of the class file.
Packages in Java allow grouping of related classes and avoid naming collisions. A package is mapped to a directory on the file system where Java files for that package are stored. There are predefined packages provided by Java and user-defined packages can also be created. Packages are specified using the package keyword and imported into other classes using import statements. The classpath variable is used to locate packages and classes for compilation and execution.
Packages in Java allow grouping of related classes and interfaces to avoid naming collisions. Some key points about packages include:
- Packages allow for code reusability and easy location of files. The Java API uses packages to organize core classes.
- Custom packages can be created by specifying the package name at the beginning of a Java file. The class files are then compiled to the corresponding directory structure.
- The import statement and fully qualified names can be used to access classes from other packages. The classpath variable specifies locations of package directories and classes.
This document discusses Java programming packages. It explains that Java API provides predefined packages organized by functionality. Packages are hierarchical, so classes can be accessed using package names and dot notation. The import statement allows accessing package classes without fully qualifying names. To create a package, the package keyword declares the name, then classes within that package are defined and stored in a subdirectory matching the package name. Packages can be accessed using import or fully qualifying class names with the package path.
Packages in Java are used to categorize classes and interfaces to facilitate organization and access protection. There are two types of packages - built-in packages that are part of the Java API, and user-defined packages that are created by the user. Classes can be imported into other packages using either "import package.*" to access all classes, "import package.classname" to access a specific class, or the fully qualified name. This allows code reuse through organizing related classes and controlling access.
This document discusses Java packages. It defines packages as groups of related classes and interfaces, and notes there are two types: system packages from the Java API and user-defined packages. It explains how to create a user-defined package by declaring the package name at the top of a file, making classes within it public, compiling the file, and importing the package. An example is provided to demonstrate creating a package with two classes and using them in a main method after importing the package.
Packages allow for organizing related classes and interfaces into namespaces to avoid naming conflicts. A package is defined using the package keyword and places class files into a directory structure that matches the package name. The classpath specifies the locations where the JVM will search for class files and external library files needed at runtime. It can be set using the -classpath option or CLASSPATH environment variable and allows packages to be accessed across directories and archives.
This document discusses packages and interfaces in Java. It defines a package as a container for classes that organizes the class namespace. Packages can be built-in or user-defined. Interfaces define method signatures but do not provide implementations. Classes can implement interfaces. The key differences between classes and interfaces are that interfaces contain only abstract methods while classes can contain concrete methods, and multiple inheritance is only possible with interfaces.
Tahmid Mobashir presented on Java packages. Packages are collections of related classes and interfaces that provide namespace management and access protection. Packages can contain subpackages and types declared in compilation units. Packages make classes easier to find, avoid naming conflicts, and control access. To create a package, a package statement with the package name is included at the top of source files containing the classes and interfaces for that package. The files are then compiled using the javac command with the -d option to place the class files in a folder matching the package name.
This document discusses Java packages and JAR archives. It explains that packages are used to organize related classes and avoid naming collisions. Classes are organized into a directory structure that matches their package hierarchy. The classpath is used to locate classes and JAR files can be used to distribute applications and resources. The document provides examples of how to declare packages, import classes, and access resources within JAR files.
This document discusses API-led connectivity and outlines three types of APIs: system APIs, process APIs, and experience APIs. System APIs connect to underlying systems and expose raw data, while process APIs combine multiple system APIs and can transform data. Experience APIs act as wrappers that clients can use to access processed data without being exposed to raw data from systems. The document also introduces the Anypoint Platform for designing, developing, managing, and monitoring APIs.
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...EduSkills OECD
Deborah Nusche, Senior Analyst, OECD presents at the OECD webinar 'Trends Spotting: Strategic foresight for tomorrow’s education systems' on 5 June 2025. You can check out the webinar on the website https://oecdedutoday.com/webinars/ Other speakers included: Deborah Nusche, Senior Analyst, OECD
Sophie Howe, Future Governance Adviser at the School of International Futures, first Future Generations Commissioner for Wales (2016-2023)
Davina Marie, Interdisciplinary Lead, Queens College London
Thomas Jørgensen, Director for Policy Coordination and Foresight at European University Association
This presentation has been made keeping in mind the students of undergraduate and postgraduate level. To keep the facts in a natural form and to display the material in more detail, the help of various books, websites and online medium has been taken. Whatever medium the material or facts have been taken from, an attempt has been made by the presenter to give their reference at the end.
In the seventh century, the rule of Sindh state was in the hands of Rai dynasty. We know the names of five kings of this dynasty- Rai Divji, Rai Singhras, Rai Sahasi, Rai Sihras II and Rai Sahasi II. During the time of Rai Sihras II, Nimruz of Persia attacked Sindh and killed him. After the return of the Persians, Rai Sahasi II became the king. After killing him, one of his Brahmin ministers named Chach took over the throne. He married the widow of Rai Sahasi and became the ruler of entire Sindh by suppressing the rebellions of the governors.
Unit- 4 Biostatistics & Research Methodology.pdfKRUTIKA CHANNE
Blocking and confounding (when a third variable, or confounder, influences both the exposure and the outcome) system for Two-level factorials (a type of experimental design where each factor (independent variable) is investigated at only two levels, typically denoted as "high" and "low" or "+1" and "-1")
Regression modeling (statistical model that estimates the relationship between one dependent variable and one or more independent variables using a line): Hypothesis testing in Simple and Multiple regression models
Introduction to Practical components of Industrial and Clinical Trials Problems: Statistical Analysis Using Excel, SPSS, MINITAB®️, DESIGN OF EXPERIMENTS, R - Online Statistical Software to Industrial and Clinical trial approach
*Order Hemiptera:*
Hemiptera, commonly known as true bugs, is a large and diverse order of insects that includes cicadas, aphids, leafhoppers, and shield bugs. Characterized by their piercing-sucking mouthparts, Hemiptera feed on plant sap, other insects, or small animals. Many species are significant pests, while others are beneficial predators.
*Order Neuroptera:*
Neuroptera, also known as net-winged insects, is an order of insects that includes lacewings, antlions, and owlflies. Characterized by their delicate, net-like wing venation and large, often prominent eyes, Neuroptera are predators that feed on other insects, playing an important role in biological control. Many species have aquatic larvae, adding to their ecological diversity.
Artificial intelligence Presented by JM.jmansha170
AI (Artificial Intelligence) :
"AI is the ability of machines to mimic human intelligence, such as learning, decision-making, and problem-solving."
Important Points about AI:
1. Learning – AI can learn from data (Machine Learning).
2. Automation – It helps automate repetitive tasks.
3. Decision Making – AI can analyze and make decisions faster than humans.
4. Natural Language Processing (NLP) – AI can understand and generate human language.
5. Vision & Recognition – AI can recognize images, faces, and patterns.
6. Used In – Healthcare, finance, robotics, education, and more.
Owner By:
Name : Junaid Mansha
Work : Web Developer and Graphics Designer
Contact us : +92 322 2291672
Email : [email protected]
Strengthened Senior High School - Landas Tool Kit.pptxSteffMusniQuiballo
Landas Tool Kit is a very helpful guide in guiding the Senior High School students on their SHS academic journey. It will pave the way on what curriculum exits will they choose and fit in.
Rose Cultivation Practices by Kushal Lamichhane.pdfkushallamichhame
This includes the overall cultivation practices of Rose prepared by:
Kushal Lamichhane (AKL)
Instructor
Shree Gandhi Adarsha Secondary School
Kageshowri Manohara-09, Kathmandu, Nepal
Adam Grant: Transforming Work Culture Through Organizational PsychologyPrachi Shah
This presentation explores the groundbreaking work of Adam Grant, renowned organizational psychologist and bestselling author. It highlights his key theories on giving, motivation, leadership, and workplace dynamics that have revolutionized how organizations think about productivity, collaboration, and employee well-being. Ideal for students, HR professionals, and leadership enthusiasts, this deck includes insights from his major works like Give and Take, Originals, and Think Again, along with interactive elements for enhanced engagement.
Parenting Teens: Supporting Trust, resilience and independencePooky Knightsmith
For more information about my speaking and training work, visit: https://www.pookyknightsmith.com/speaking/
SESSION OVERVIEW:
Parenting Teens: Supporting Trust, Resilience & Independence
The teenage years bring new challenges—for teens and for you. In this practical session, we’ll explore how to support your teen through emotional ups and downs, growing independence, and the pressures of school and social life.
You’ll gain insights into the teenage brain and why boundary-pushing is part of healthy development, along with tools to keep communication open, build trust, and support emotional resilience. Expect honest ideas, relatable examples, and space to connect with other parents.
By the end of this session, you will:
• Understand how teenage brain development affects behaviour and emotions
• Learn ways to keep communication open and supportive
• Explore tools to help your teen manage stress and bounce back from setbacks
• Reflect on how to encourage independence while staying connected
• Discover simple strategies to support emotional wellbeing
• Share experiences and ideas with other parents
Different pricelists for different shops in odoo Point of Sale in Odoo 17Celine George
Price lists are a useful tool for managing the costs of your goods and services. This can assist you in working with other businesses effectively and maximizing your revenues. Additionally, you can provide your customers discounts by using price lists.
Completed Sunday 6/8. For Weekend 6/14 & 15th. (Fathers Day Weekend US.) These workshops are also timeless for future students TY. No admissions needed.
A 9th FREE WORKSHOP
Reiki - Yoga
“Intuition-II, The Chakras”
Your Attendance is valued.
We hit over 5k views for Spring Workshops and Updates-TY.
Thank you for attending our workshops.
If you are new, do welcome.
Grad Students: I am planning a Reiki-Yoga Master Course (As a package). I’m Fusing both together.
This will include the foundation of each practice. Our Free Workshops can be used with any Reiki Yoga training package. Traditional Reiki does host rules and ethics. Its silent and within the JP Culture/Area/Training/Word of Mouth. It allows remote healing but there’s limits As practitioners and masters, we are not allowed to share certain secrets/tools. Some content is designed only for “Masters”. Some yoga are similar like the Kriya Yoga-Church (Vowed Lessons). We will review both Reiki and Yoga (Master tools) in the Course upcoming.
S9/This Week’s Focus:
* A continuation of Intuition-2 Development. We will review the Chakra System - Our temple. A misguided, misused situation lol. This will also serve Attunement later.
Thx for tuning in. Your time investment is valued. I do select topics related to our timeline and community. For those seeking upgrades or Reiki Levels. Stay tuned for our June packages. It’s for self employed/Practitioners/Coaches…
Review & Topics:
* Reiki Is Japanese Energy Healing used Globally.
* Yoga is over 5k years old from India. It hosts many styles, teacher versions, and it’s Mainstream now vs decades ago.
* Anything of the Holistic, Wellness Department can be fused together. My origins are Alternative, Complementary Medicine. In short, I call this ND. I am also a metaphysician. I learnt during the 90s New Age Era. I forget we just hit another wavy. It’s GenZ word of Mouth, their New Age Era. WHOA, History Repeats lol. We are fusing together.
* So, most of you have experienced your Spiritual Awakening. However; The journey wont be perfect. There will be some roller coaster events. The perks are: We are in a faster Spiritual Zone than the 90s. There’s more support and information available.
(See Presentation for all sections, THX AGAIN.)
How to Configure Vendor Management in Lunch App of Odoo 18Celine George
The Vendor management in the Lunch app of Odoo 18 is the central hub for managing all aspects of the restaurants or caterers that provide food for your employees.
A short update and next week. I am writing both Session 9 and Orientation S1.
As a Guest Student,
You are now upgraded to Grad Level.
See Uploads for “Student Checkin” & “S8”. Thx.
Thank you for attending our workshops.
If you are new, do welcome.
Grad Students: I am planning a Reiki-Yoga Master Course (As a package). I’m Fusing both together.
This will include the foundation of each practice. Our Free Workshops can be used with any Reiki Yoga training package. Traditional Reiki does host rules and ethics. Its silent and within the JP Culture/Area/Training/Word of Mouth. It allows remote healing but there’s limits As practitioners and masters. We are not allowed to share certain secrets/tools. Some content is designed only for “Masters”. Some yoga are similar like the Kriya Yoga-Church (Vowed Lessons). We will review both Reiki and Yoga (Master tools) in the Course upcoming.
Session Practice, For Reference:
Before starting a session, Make sure to check your environment. Nothing stressful. Later, You can decorate a space as well.
Check the comfort level, any needed resources (Yoga/Reiki/Spa Props), or Meditation Asst?
Props can be oils, sage, incense, candles, crystals, pillows, blankets, yoga mat, any theme applies.
Select your comfort Pose. This can be standing, sitting, laying down, or a combination.
Monitor your breath. You can add exercises.
Add any mantras or affirmations. This does aid mind and spirit. It helps you to focus.
Also you can set intentions using a candle.
The Yoga-key is balancing mind, body, and spirit.
Finally, The Duration can be long or short.
Its a good session base for any style.
Next Week’s Focus:
A continuation of Intuition Development. We will review the Chakra System - Our temple. A misguided, misused situation lol. This will also serve Attunement later.
For Sponsor,
General updates,
& Donations:
Please visit:
https://ldmchapels.weebly.com
2. Packages
• Packages are Java’s way of grouping a number of related classes
and/or interfaces together into a single unit. That means, packages
act as “containers” for classes.
• The benefits of organising classes into packages are:
- The classes contained in the packages of other
programs/applications can be reused.
- In packages classes can be unique compared with classes in other
packages. That two classes in two different packages can have the
same name. If there is a naming clash, then classes can be accessed
with their fully qualified name.
- Classes in packages can be hidden if we don’t want other packages
to access them.
- Packages also provide a way for separating “design” from coding.
3. Java Foundation Packages
Java provides a large number of classes groped into different packages based on
their functionality
• The six foundation Java packages are:
- java.lang :
Contains classes for primitive types, strings, math functions, threads, and
exception.
- java.util :
Contains classes such as vectors, hash tables, date etc.
- java.io :
Stream classes for I/O .
- java.awt :
Classes for implementing GUI – windows, buttons, menus etc.
- java.net :
Classes for networking .
- java.applet :
Classes for creating and implementing app.
4. Using System Packages
• The packages are organised in a hierarchical structure .For example, a package
named “java” contains the package “awt”, which in turn contains various classes
required for implementing GUI (graphical user interface).
Java “java” Package containing
“lang”, “awt”,.. packages;
Can also contain classes.
awt package containing classes. Classes containing
methods
lang
graphics
font
image
awt
5. Accessing Classes from Packages
There are two ways of accessing the classes stored in packages:
• Using fully qualified class name
java.lang.Math.sqrt(x);
• Import package and use class name directly
import java.lang.Math
Math.sqrt(x);
• Selected or all classes in packages can be imported:
• Implicit in all programs: import java.lang.*;
• package statement(s) must appear first
import package.class;
import package.*;
6. Creating Packages
Java supports a keyword called “package” for creating user-defined
packages. The package statement must be the first statement in a Java
source file (except comments and white spaces) followed by one or more
classes.
package myPackage;
public class ClassA {
// class body
}
class ClassB {
}
Package name is “myPackage” and classes are considered as part
of this package; The code is saved in a file called “ClassA.java” and located
in a directory called “myPackage”.
7. Accessing a Package
• As indicated earlier, classes in packages can be
accessed using a fully qualified name or using a short-
cut as long as we import a corresponding package.
• The general form of importing package is:
import package1[.package2][…].classname
• Example:
import myPackage.ClassA;
import myPackage.secondPackage
• All classes/packages from higher-level package can be
imported as follows:
import myPackage.*;
8. Using a Package
• Let us store the code listing below in a file named“ClassA.java” within
subdirectory named “myPackage”within the current directory (say “abc”).
• package myPackage;
• public class ClassA {
• // class body
• public void display()
• {
• System.out.println("Hello, I am ClassA");
• }
• }
• class ClassB {
• // class body
• }
9. Using a Package
Within the current directory (“abc”) store the following
code in a file named“ClassX.java”
import myPackage.ClassA;
public class ClassX
{
public static void main(String args[])
{
ClassA objA = new ClassA();
objA.display();
}
}
10. Compiling and Running
• en ClassX.java is compiled, the compiler compiles it and places .class file in
current directly. If .class of ClassA in subdirectory “myPackage” is not
found, it comples ClassA also.
• Note: It does not include code of ClassA into ClassX ✞
• When the program ClassX is run, java loader looks for ClassA.class file in a
package called “myPackage” and loads it.
11. Using a Package
Let us store the code listing below in a file named“ClassA.java” within
subdirectory named“secondPackage” within the current directory
(say“abc”).
public class ClassC {
// class body
public void display()
{
System.out.println("Hello, I am ClassC");
}
}
12. Using a Package
• Within the current directory (“abc”) store the following code in a file
named“ClassX.java”
• import myPackage.ClassA;
• import secondPackage.ClassC;
• public class ClassY
• {
• public static void main(String args[])
• {
• ClassA objA = new ClassA();
• ClassC objC = new ClassC();
• objA.display();
• objC.display();
• }
• }