SlideShare une entreprise Scribd logo
1  sur  14
Télécharger pour lire hors ligne
JAVA PROGRAMMING –
Packages - Stream based I/O
Dr R Jegadeesan Prof-CSE
Jyothishmathi Institute of Technology and Science,
Karimnagar
SYLLABUS
Packages- Defining a Package, CLASSPATH, Access protection, importing
packages. Interfaces- defining an interface, implementing interfaces,
Nested interfaces, applying interfaces, variables in interfaces and extending
interfaces.
Stream based I/O (java.io) – The Stream classes-Byte streams and
Character streams, Reading console Input and Writing Console Output, File
class, Reading and writing Files, Random access file operations, The
Console class, Serialization, Enumerations, auto boxing, generics.
UNIT 2 : PACKAGES, INTERFACES, STREAM BASED I/O
Topic Name : Introduction to Packages, Interfaces, Stream based I/O
Topic : Introduction to Packages, Interfaces, Stream Based I/O
Aim & Objective : To make the student understand the concepts of creation of
packages, interfaces and stream classes
Application With Example :Java programs to create and access the packages and
implementing interfaces. Java program to read and write data from and to streams.
Limitations If Any :
Reference Links :
• http://javabeginnerstutorial.com/core-java/
• Java The complete reference, 9th edition, Herbert Schildt, McGraw Hill Education
(India) Pvt. Ltd.
• https://www.tutorialride.com/core-java/packages-interfaces-in-java.htm
• Video Link details
• https://www.youtube.com/watch?v=iIwyrdc3Zvw
Universities & Important Questions :
• Define a package. What is the necessity of packages?
• What are the packages provided by Java API?
• Discuss about packages of java language
• What is a package? How do we design a package?
• What is package? Explain the procedure to create a package with the help of example
• How do you create a package? Explain about access protection in packages.
• What is the major difference between an interface and class?
• Compare and contrast between class and an interface.
• Define abstract class and interface and what the difference between them and
explain with Suitable examples
• How to design and implement an interface? Explain with example.
• What is multiple inheritance? Explain how it can be implemented in Java with the
help of an example
• Explain how interfaces can be implemented.
• Write an interface called Shape with necessary methods. Derived classes circle,
rectangle, triangle, cone, sphere and cube with appropriate constructors and
methods for area, volume also setting and displaying.
• Java does not support multiple inheritance. Then how is the problem solved explain
with suitable example.
▪ Packages
▪ Interfaces
▪ Stream based I/O
▪ Serialization
▪ Enumeration
▪ Generics
UNIT – II
CONTENTS
Interfaces
• In Java, only single inheritance is permitted. However, Java
provides a construct called an interface which can be
implemented by a class.
• Interfaces are similar to abstract classes (we will compare the
two soon).
• A class can implement any number of interfaces. In effect
using interfaces gives us the benefit of multiple inheritance
without many of it’s problems.
• Interfaces are compiled into bytecode just like classes.
• Interfaces cannot be instantiated.
• Can use interface as a data type for variables.
• Can also use an interface as the result of a cast operation.
• Interfaces can contain only abstract methods and constants.
Interfaces (cont)
• An interface is created with the following
syntax:
modifier interface interfaceID
{
//constants/method signatures
}
Syntax
public class Circle extends
GeometricObject implements
Comparable {
/* define class here make sure
to implement all the abstract
methods contained in the
interface(s)*/
}
Interfaces (cont)
• An interface can extend other interfaces with the following
syntax:
modifier interface interfaceID extends
comma-delimited-list-of-interfaces
{
//constants/method signatures
}
• Obviously, any class which implements a “sub-interface” will
have to implement each of the methods contained in it’s
“super-interfaces”
Interface Abstract class
Fields Only constants Constants and
variable data
Methods No implementation
allowed (no
abstract modifier
necessary)
Abstract or
concrete
Interface vs. abstract class
Interface vs. abstract class (cont)
Interface Abstract class
Inheritance A subclass can
implement many
interfaces
A subclass can
inherit only one
class
Can extend
numerous
interfaces
Can implement
numerous
interfaces
Cannot extend a
class
Extends one class
Interface vs. abstract class (cont)
Interface Abstract class
Root none Object (of all
classes)
names Adjective or
Nouns
Nouns
Comparable interface
• This interface imposes a total ordering on the
objects of each class that implements it. This
ordering is referred to as the class's natural
ordering, and the class's compareTo method is
referred to as its natural comparison method.
int compareTo (Object o)
Compares this object with the specified object for
order. Returns a negative integer, zero, or a
positive integer as this object is less than, equal to,
or greater than the specified object.
Thank you

Contenu connexe

Tendances

java-06inheritance
java-06inheritancejava-06inheritance
java-06inheritance
Arjun Shanka
 
5.interface and packages
5.interface and packages5.interface and packages
5.interface and packages
Deepak Sharma
 

Tendances (20)

Pi j4.1 packages
Pi j4.1 packagesPi j4.1 packages
Pi j4.1 packages
 
Introduction to java
Introduction to  javaIntroduction to  java
Introduction to java
 
Dacj 2-1 a
Dacj 2-1 aDacj 2-1 a
Dacj 2-1 a
 
packages and interfaces
packages and interfacespackages and interfaces
packages and interfaces
 
java-06inheritance
java-06inheritancejava-06inheritance
java-06inheritance
 
java interface and packages
java interface and packagesjava interface and packages
java interface and packages
 
inheritance
inheritanceinheritance
inheritance
 
5.interface and packages
5.interface and packages5.interface and packages
5.interface and packages
 
Multiple inheritance possible in Java
Multiple inheritance possible in JavaMultiple inheritance possible in Java
Multiple inheritance possible in Java
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
 
Java access modifiers
Java access modifiersJava access modifiers
Java access modifiers
 
Unit3 packages & interfaces
Unit3 packages & interfacesUnit3 packages & interfaces
Unit3 packages & interfaces
 
Java package
Java packageJava package
Java package
 
Inner classes in java
Inner classes in javaInner classes in java
Inner classes in java
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 
Inheritance and Polymorphism
Inheritance and PolymorphismInheritance and Polymorphism
Inheritance and Polymorphism
 
Java Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overridingJava Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overriding
 
Java Object Oriented Programming
Java Object Oriented Programming Java Object Oriented Programming
Java Object Oriented Programming
 
Packages
PackagesPackages
Packages
 

Similaire à JAVA PROGRAMMING – Packages - Stream based I/O

Top 371 java fa qs useful for freshers and experienced
Top 371 java fa qs useful for freshers and experiencedTop 371 java fa qs useful for freshers and experienced
Top 371 java fa qs useful for freshers and experienced
Gaurav Maheshwari
 
Java Faqs useful for freshers and experienced
Java Faqs useful for freshers and experiencedJava Faqs useful for freshers and experienced
Java Faqs useful for freshers and experienced
yearninginjava
 
Understanding And Using Reflection
Understanding And Using ReflectionUnderstanding And Using Reflection
Understanding And Using Reflection
Ganesh Samarthyam
 

Similaire à JAVA PROGRAMMING – Packages - Stream based I/O (20)

Core_Java_Interview.pdf
Core_Java_Interview.pdfCore_Java_Interview.pdf
Core_Java_Interview.pdf
 
Java 6.pptx
Java 6.pptxJava 6.pptx
Java 6.pptx
 
Interface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar SinghInterface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar Singh
 
Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in java
 
Interface &packages
Interface &packagesInterface &packages
Interface &packages
 
What is Interface in Java | How to implement Multiple Inheritance Using Inter...
What is Interface in Java | How to implement Multiple Inheritance Using Inter...What is Interface in Java | How to implement Multiple Inheritance Using Inter...
What is Interface in Java | How to implement Multiple Inheritance Using Inter...
 
Inheritance.pptx
Inheritance.pptxInheritance.pptx
Inheritance.pptx
 
Unit 4
Unit 4Unit 4
Unit 4
 
Suga java training_with_footer
Suga java training_with_footerSuga java training_with_footer
Suga java training_with_footer
 
Core java questions
Core java questionsCore java questions
Core java questions
 
Top 371 java fa qs useful for freshers and experienced
Top 371 java fa qs useful for freshers and experiencedTop 371 java fa qs useful for freshers and experienced
Top 371 java fa qs useful for freshers and experienced
 
Java Faqs useful for freshers and experienced
Java Faqs useful for freshers and experiencedJava Faqs useful for freshers and experienced
Java Faqs useful for freshers and experienced
 
Abstraction in Java: Abstract class and Interfaces
Abstraction in  Java: Abstract class and InterfacesAbstraction in  Java: Abstract class and Interfaces
Abstraction in Java: Abstract class and Interfaces
 
Csci360 20 (1)
Csci360 20 (1)Csci360 20 (1)
Csci360 20 (1)
 
Csci360 20
Csci360 20Csci360 20
Csci360 20
 
oop unit1.pptx
oop unit1.pptxoop unit1.pptx
oop unit1.pptx
 
Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in java
 
Pi j3.2 polymorphism
Pi j3.2 polymorphismPi j3.2 polymorphism
Pi j3.2 polymorphism
 
CS8392 OOP
CS8392 OOPCS8392 OOP
CS8392 OOP
 
Understanding And Using Reflection
Understanding And Using ReflectionUnderstanding And Using Reflection
Understanding And Using Reflection
 

Plus de Jyothishmathi Institute of Technology and Science Karimnagar

Plus de Jyothishmathi Institute of Technology and Science Karimnagar (20)

JAVA PROGRAMMING- GUI Programming with Swing - The Swing Buttons
JAVA PROGRAMMING- GUI Programming with Swing - The Swing ButtonsJAVA PROGRAMMING- GUI Programming with Swing - The Swing Buttons
JAVA PROGRAMMING- GUI Programming with Swing - The Swing Buttons
 
JAVA PROGRAMMING - The Collections Framework
JAVA PROGRAMMING - The Collections Framework JAVA PROGRAMMING - The Collections Framework
JAVA PROGRAMMING - The Collections Framework
 
JAVA PROGRAMMING- Exception handling - Multithreading
JAVA PROGRAMMING- Exception handling - MultithreadingJAVA PROGRAMMING- Exception handling - Multithreading
JAVA PROGRAMMING- Exception handling - Multithreading
 
WEB TECHNOLOGIES JavaScript
WEB TECHNOLOGIES JavaScriptWEB TECHNOLOGIES JavaScript
WEB TECHNOLOGIES JavaScript
 
WEB TECHNOLOGIES JSP
WEB TECHNOLOGIES  JSPWEB TECHNOLOGIES  JSP
WEB TECHNOLOGIES JSP
 
WEB TECHNOLOGIES Servlet
WEB TECHNOLOGIES ServletWEB TECHNOLOGIES Servlet
WEB TECHNOLOGIES Servlet
 
WEB TECHNOLOGIES XML
WEB TECHNOLOGIES XMLWEB TECHNOLOGIES XML
WEB TECHNOLOGIES XML
 
WEB TECHNOLOGIES- PHP Programming
WEB TECHNOLOGIES-  PHP ProgrammingWEB TECHNOLOGIES-  PHP Programming
WEB TECHNOLOGIES- PHP Programming
 
Compiler Design- Machine Independent Optimizations
Compiler Design- Machine Independent OptimizationsCompiler Design- Machine Independent Optimizations
Compiler Design- Machine Independent Optimizations
 
COMPILER DESIGN Run-Time Environments
COMPILER DESIGN Run-Time EnvironmentsCOMPILER DESIGN Run-Time Environments
COMPILER DESIGN Run-Time Environments
 
COMPILER DESIGN- Syntax Directed Translation
COMPILER DESIGN- Syntax Directed TranslationCOMPILER DESIGN- Syntax Directed Translation
COMPILER DESIGN- Syntax Directed Translation
 
COMPILER DESIGN- Syntax Analysis
COMPILER DESIGN- Syntax AnalysisCOMPILER DESIGN- Syntax Analysis
COMPILER DESIGN- Syntax Analysis
 
COMPILER DESIGN- Introduction & Lexical Analysis:
COMPILER DESIGN- Introduction & Lexical Analysis: COMPILER DESIGN- Introduction & Lexical Analysis:
COMPILER DESIGN- Introduction & Lexical Analysis:
 
CRYPTOGRAPHY AND NETWORK SECURITY- E-Mail Security
CRYPTOGRAPHY AND NETWORK SECURITY- E-Mail SecurityCRYPTOGRAPHY AND NETWORK SECURITY- E-Mail Security
CRYPTOGRAPHY AND NETWORK SECURITY- E-Mail Security
 
CRYPTOGRAPHY AND NETWORK SECURITY- Transport-level Security
CRYPTOGRAPHY AND NETWORK SECURITY- Transport-level SecurityCRYPTOGRAPHY AND NETWORK SECURITY- Transport-level Security
CRYPTOGRAPHY AND NETWORK SECURITY- Transport-level Security
 
CRYPTOGRAPHY & NETWORK SECURITY- Cryptographic Hash Functions
CRYPTOGRAPHY & NETWORK SECURITY- Cryptographic Hash FunctionsCRYPTOGRAPHY & NETWORK SECURITY- Cryptographic Hash Functions
CRYPTOGRAPHY & NETWORK SECURITY- Cryptographic Hash Functions
 
CRYPTOGRAPHY & NETWOK SECURITY- Symmetric key Ciphers
CRYPTOGRAPHY & NETWOK SECURITY- Symmetric key CiphersCRYPTOGRAPHY & NETWOK SECURITY- Symmetric key Ciphers
CRYPTOGRAPHY & NETWOK SECURITY- Symmetric key Ciphers
 
CRYPTOGRAPHY & NETWORK SECURITY
CRYPTOGRAPHY & NETWORK SECURITYCRYPTOGRAPHY & NETWORK SECURITY
CRYPTOGRAPHY & NETWORK SECURITY
 
Computer Forensics Working with Windows and DOS Systems
Computer Forensics Working with Windows and DOS SystemsComputer Forensics Working with Windows and DOS Systems
Computer Forensics Working with Windows and DOS Systems
 
Current Forensic Tools
Current Forensic Tools Current Forensic Tools
Current Forensic Tools
 

Dernier

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Dernier (20)

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

JAVA PROGRAMMING – Packages - Stream based I/O

  • 1. JAVA PROGRAMMING – Packages - Stream based I/O Dr R Jegadeesan Prof-CSE Jyothishmathi Institute of Technology and Science, Karimnagar
  • 2. SYLLABUS Packages- Defining a Package, CLASSPATH, Access protection, importing packages. Interfaces- defining an interface, implementing interfaces, Nested interfaces, applying interfaces, variables in interfaces and extending interfaces. Stream based I/O (java.io) – The Stream classes-Byte streams and Character streams, Reading console Input and Writing Console Output, File class, Reading and writing Files, Random access file operations, The Console class, Serialization, Enumerations, auto boxing, generics.
  • 3. UNIT 2 : PACKAGES, INTERFACES, STREAM BASED I/O Topic Name : Introduction to Packages, Interfaces, Stream based I/O Topic : Introduction to Packages, Interfaces, Stream Based I/O Aim & Objective : To make the student understand the concepts of creation of packages, interfaces and stream classes Application With Example :Java programs to create and access the packages and implementing interfaces. Java program to read and write data from and to streams. Limitations If Any : Reference Links : • http://javabeginnerstutorial.com/core-java/ • Java The complete reference, 9th edition, Herbert Schildt, McGraw Hill Education (India) Pvt. Ltd. • https://www.tutorialride.com/core-java/packages-interfaces-in-java.htm • Video Link details • https://www.youtube.com/watch?v=iIwyrdc3Zvw
  • 4. Universities & Important Questions : • Define a package. What is the necessity of packages? • What are the packages provided by Java API? • Discuss about packages of java language • What is a package? How do we design a package? • What is package? Explain the procedure to create a package with the help of example • How do you create a package? Explain about access protection in packages. • What is the major difference between an interface and class? • Compare and contrast between class and an interface. • Define abstract class and interface and what the difference between them and explain with Suitable examples • How to design and implement an interface? Explain with example. • What is multiple inheritance? Explain how it can be implemented in Java with the help of an example • Explain how interfaces can be implemented. • Write an interface called Shape with necessary methods. Derived classes circle, rectangle, triangle, cone, sphere and cube with appropriate constructors and methods for area, volume also setting and displaying. • Java does not support multiple inheritance. Then how is the problem solved explain with suitable example.
  • 5. ▪ Packages ▪ Interfaces ▪ Stream based I/O ▪ Serialization ▪ Enumeration ▪ Generics UNIT – II CONTENTS
  • 6. Interfaces • In Java, only single inheritance is permitted. However, Java provides a construct called an interface which can be implemented by a class. • Interfaces are similar to abstract classes (we will compare the two soon). • A class can implement any number of interfaces. In effect using interfaces gives us the benefit of multiple inheritance without many of it’s problems. • Interfaces are compiled into bytecode just like classes. • Interfaces cannot be instantiated. • Can use interface as a data type for variables. • Can also use an interface as the result of a cast operation. • Interfaces can contain only abstract methods and constants.
  • 7. Interfaces (cont) • An interface is created with the following syntax: modifier interface interfaceID { //constants/method signatures }
  • 8. Syntax public class Circle extends GeometricObject implements Comparable { /* define class here make sure to implement all the abstract methods contained in the interface(s)*/ }
  • 9. Interfaces (cont) • An interface can extend other interfaces with the following syntax: modifier interface interfaceID extends comma-delimited-list-of-interfaces { //constants/method signatures } • Obviously, any class which implements a “sub-interface” will have to implement each of the methods contained in it’s “super-interfaces”
  • 10. Interface Abstract class Fields Only constants Constants and variable data Methods No implementation allowed (no abstract modifier necessary) Abstract or concrete Interface vs. abstract class
  • 11. Interface vs. abstract class (cont) Interface Abstract class Inheritance A subclass can implement many interfaces A subclass can inherit only one class Can extend numerous interfaces Can implement numerous interfaces Cannot extend a class Extends one class
  • 12. Interface vs. abstract class (cont) Interface Abstract class Root none Object (of all classes) names Adjective or Nouns Nouns
  • 13. Comparable interface • This interface imposes a total ordering on the objects of each class that implements it. This ordering is referred to as the class's natural ordering, and the class's compareTo method is referred to as its natural comparison method. int compareTo (Object o) Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.