Skip to main content Accessibility help
Internet Explorer 11 is being discontinued by Microsoft in August 2021. If you have difficulties viewing the site on Internet Explorer 11 we recommend using a different browser such as Microsoft Edge, Google Chrome, Apple Safari or Mozilla Firefox.

Chapter 5: Package and Interface

Chapter 5: Package and Interface

pp. 287-359

Authors

, Indian Institute of Technology, Kharagpur, , Indian Institute of Technology, Kharagpur
  • Add bookmark
  • Cite
  • Share

Extract

Package and interface are two incredible concepts in Java programming language. These features make Java programming suitable for developing large software in any application domain. The concept of package and interface allows the programmers to organize classes and hence methods and fields or constants for developing a large software program. This concept is called programming in large. It also helps the programmers to write code in their own styles, which is called programming in small. With this you will feel Java is like C when programming in small and like Smalltalk (a pure object-oriented programming language) when programming in large. This means that Java is powerful like any function-oriented programming language while you are coding individual lines, and has the extensibility and expressive power of a pure object-oriented programming language while you’re designing.

Introduction

From design to coding The separation of “designing” from “coding” was one of the most fundamental advances in programming style in the recent past, and object-oriented languages are capable of implementing a strong form of this separation. According to this programming paradigm, you design the classes first and decide the relationships between these classes, and then you implement the Java code needed for each of the methods in your class design. The advantages with this style is that, you can change your mind about aspects of the design without affecting anything but small, local pieces of your programs; vice-versa, you can change the implementation of any method without affecting the design.

To achieve this, the Java developer includes two very innovative features: package and interface. Packages provide class repositories, grouping them together, and controlling their access to the outside world. Interfaces provide a way of grouping abstract method definitions and sharing them among classes.

Your learning This chapter plans to discuss the package and interface concepts in Java. You will learn how to design, use, and create your own packages and interfaces. The specific topics which you will learn include: a detailed discussion of designing classes and coding classes; what are packages and why they are useful for designing classes; using other available packages in your own classes; how you can create your own packages; what interfaces you can utilize in terms of code reuse and design; designing and working with interfaces; and many more.

About the book

Access options

Review the options below to login to check your access.

Purchase options

eTextbook
US$99.99
Paperback
US$99.99

Have an access code?

To redeem an access code, please log in with your personal login.

If you believe you should have access to this content, please contact your institutional librarian or consult our FAQ page for further information about accessing our content.

Also available to purchase from these educational ebook suppliers