Skip To Content7
Skip To Content7
Skip To Content7
geeksforgeeks
Courses 90% Refund
Tutorials
Java
Practice
Contests
Sign In
Java Arrays
Java Strings
Java OOPs
Java Collection
Java 8 Tutorial
Java Multithreading
Java Exception Handling
Java Programs
Java Project
Java Collections Interview
Java Interview Questions
Java MCQs
Spring
Spring MVC
Spring Boot
Hibernate
import package.name.*;
Example: Importing java.util package
// Main Class
class GFG {
// Display message
// Enter Your Name And Press Enter
System.out.println("Enter Your Name:");
First We Should Choose A Name For The Package We Are Going To Create And Include.
The package command In The first line in the java program source code.
Further inclusion of classes, interfaces, annotation types, etc that is required in
the package can be made in the package. For example, the below single statement
creates a package name called “FirstPackage”.
Syntax: To declare the name of the package to be created. The package statement
simply defines in which package the classes defined belong.
package FirstPackage ;
Implementation: To Create a Class Inside A Package
First Declare The Package Name As The First Statement Of Our Program.
Then We Can Include A Class As A Part Of The Package.
Example 1: Creating a Class Inside a Package
Output
Example 2: Another Package Example
// Print message
System.out.println("Hi Everyone");
}
// Method 2 - To show()
public void view()
{
// Print message
System.out.println("Hello");
}
}
Again, in order to generate the above-desired output first do use the commands as
specified use the following specified commands
Procedure:
Hi Everyone
Hello
Three 90 Challenge is back on popular demand! After processing refunds worth INR
1CR+, we are back with the offer if you missed it the first time. Get 90% course
fee refund in 90 days. Avail now!
Feeling lost in the vast world of Backend Development? It's time for a change! Join
our Java Backend Development - Live Course and embark on an exciting journey to
master backend development efficiently and on schedule.
What We Offer:
Comprehensive Course
Expert Guidance for Efficient Learning
Hands-on Experience with Real-world Projects
Proven Track Record with 100,000+ Successful Geeks
nishanthec19
36
Previous Article
Packages In Java
Next Article
Java.util Package in Java
Read More
Down Arrow
Similar Reads
Java Program to Create a Package to Access the Member of External Class and Same
Package
As the name suggests a package in java that contains all the same kinds of classes,
Abstract classes, interfaces, etc that have the same functionality. A Single
package can contain many classes, Abstract classes e.g. java.util package etc.
There are two types of packages: Built-in-package: These are the packages that are
predefined in the java jar
2 min read
Java.lang.Package class in Java
Java 2 added a class called Package that encapsulates version data associated with
a package. Package version information is becoming more important because of the
proliferation of packages and because a java program may need to know what version
of a package is available. This versioning information is retrieved and made
available by the ClassLoad
8 min read
Java.util Package in Java
Java.util PackageIt contains the collections framework, legacy collection classes,
event model, date and time facilities, internationalization, and miscellaneous
utility classes (a string tokenizer, a random-number generator, and a bit
array).Following are the Important Classes in Java.util package :
AbstractCollection: This class provides a skelet
4 min read
Java.lang package in Java
Java.lang package in JavaProvides classes that are fundamental to the design of the
Java programming language. The most important classes are Object, which is the root
of the class hierarchy, and Class, instances of which represent classes at run
time. Following are the Important Classes in Java.lang package : Boolean: The
Boolean class wraps a val
3 min read
Java.io Package in Java
Java.io Package in JavaThis package provides for system input and output through
data streams, serialization and the file system. Unless otherwise noted, passing a
null argument to a constructor or method in any class or interface in this package
will cause a NullPointerException to be thrown. Following are the important classes
in Java.io package:
1 min read
HTTP API of java.net.http Package With Examples
HTTP Client and WebSocket APIs provide high-level client interfaces to HTTP
(versions 1.1 and 2) and low-level client interfaces to WebSocket. The main types
defined are namely as follows: HttpClientHttpRequestHttpResponse The protocol-
specific requirements are defined in the Hypertext Transfer Protocol Version 2
(HTTP/2), the Hypertext Transfer Pr
14 min read
javax.xml.crypto Package in Java
Common classes having the XML cryptography for the Package javax.xml.crypto. now
this crypto package includes similar classes that are used to accessing XML
cryptographic on its operations, such as creating an XML signature or encrypted XML
data. There are two types of javax.xml.crypto classes in this package that are
KeySelector class, which allow
4 min read
Package getSpecificationVendor() method in Java with Examples
The getSpecificationVendor() method of java.lang.Package class is used to get the
vendor of the specification of this package. The method returns the specification
vendor of the package as a String.Syntax: public String getSpecificationVendor()
Parameter: This method does not accept any parameter.Return Value: This method
returns the specification
2 min read
Package getImplementationTitle() method in Java with Examples
The getImplementationTitle() method of java.lang.Package class is used to get the
title of the implementation of this package. The method returns the implementation
title of the package as a String.Syntax: public String getImplementationTitle()
Parameter: This method does not accept any parameter.Return Value: This method
returns the implementation
2 min read
Package getImplementationVersion() method in Java with Examples
The getImplementationVersion() method of java.lang.Package class is used to get the
version of the implementation of this package. The method returns the
implementation version of the package as a String.Syntax: public String
getImplementationVersion() Parameter: This method does not accept any
parameter.Return Value: This method returns the implem
2 min read
Article Tags :
Java
Java Programs
Java-Packages
Practice Tags :
Java
three90RightbarBannerImg
course-img
214k+ interested Geeks
JAVA Backend Development - Live
Avail 90% Refund
course-img
30k+ interested Geeks
Manual to Automation Testing: A QA Engineer's Guide
Avail 90% Refund
course-img
216k+ interested Geeks
Java Programming Online Course [Complete Beginner to Advanced]
Avail 90% Refund
geeksforgeeks-footer-logo
Corporate & Communications Address:- A-143, 9th Floor, Sovereign Corporate Tower,
Sector- 136, Noida, Uttar Pradesh (201305) | Registered Address:- K 061, Tower K,
Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh,
201305
GFG App on Play Store
GFG App on App Store
Company
About Us
Legal
Careers
In Media
Contact Us
Advertise with us
GFG Corporate Solution
Placement Training Program
Explore
Job-A-Thon Hiring Challenge
Hack-A-Thon
GfG Weekly Contest
Offline Classes (Delhi/NCR)
DSA in JAVA/C++
Master System Design
Master CP
GeeksforGeeks Videos
Geeks Community
Languages
Python
Java
C++
PHP
GoLang
SQL
R Language
Android Tutorial
DSA
Data Structures
Algorithms
DSA for Beginners
Basic DSA Problems
DSA Roadmap
DSA Interview Questions
Competitive Programming
Data Science & ML
Data Science With Python
Data Science For Beginner
Machine Learning Tutorial
ML Maths
Data Visualisation Tutorial
Pandas Tutorial
NumPy Tutorial
NLP Tutorial
Deep Learning Tutorial
Web Technologies
HTML
CSS
JavaScript
TypeScript
ReactJS
NextJS
NodeJs
Bootstrap
Tailwind CSS
Python Tutorial
Python Programming Examples
Django Tutorial
Python Projects
Python Tkinter
Web Scraping
OpenCV Tutorial
Python Interview Question
Computer Science
GATE CS Notes
Operating Systems
Computer Network
Database Management System
Software Engineering
Digital Logic Design
Engineering Maths
DevOps
Git
AWS
Docker
Kubernetes
Azure
GCP
DevOps Roadmap
System Design
High Level Design
Low Level Design
UML Diagrams
Interview Guide
Design Patterns
OOAD
System Design Bootcamp
Interview Questions
School Subjects
Mathematics
Physics
Chemistry
Biology
Social Science
English Grammar
Commerce
Accountancy
Business Studies
Economics
Management
HR Management
Finance
Income Tax
Databases
SQL
MYSQL
PostgreSQL
PL/SQL
MongoDB
Preparation Corner
Company-Wise Recruitment Process
Resume Templates
Aptitude Preparation
Puzzles
Company-Wise Preparation
Companies
Colleges
Competitive Exams
JEE Advanced
UGC NET
UPSC
SSC CGL
SBI PO
SBI Clerk
IBPS PO
IBPS Clerk
More Tutorials
Software Development
Software Testing
Product Management
Project Management
Linux
Excel
All Cheat Sheets
Recent Articles
Free Online Tools
Typing Test
Image Editor
Code Formatters
Code Converters
Currency Converter
Random Number Generator
Random Password Generator
Write & Earn
Write an Article
Improve an Article
Pick Topics to Write
Share your Experiences
Internships
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By
using our site, you acknowledge that you have read and understood our Cookie Policy
& Privacy Policy
Got It !
Lightbox