Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Java 9 with JShell

You're reading from   Java 9 with JShell Introducing the full range of Java 9's new features via JShell

Arrow left icon
Product type Paperback
Published in Mar 2017
Publisher Packt
ISBN-13 9781787282841
Length 408 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Gaston C. Hillar Gaston C. Hillar
Author Profile Icon Gaston C. Hillar
Gaston C. Hillar
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. JShell – A Read-Evaluate-Print-Loop for Java 9 2. Real-World Objects to UML Diagrams and Java 9 via JShell FREE CHAPTER 3. Classes and Instances 4. Encapsulation of Data 5. Mutable and Immutable Classes 6. Inheritance, Abstraction, Extension, and Specialization 7. Members Inheritance and Polymorphism 8. Contract Programming with Interfaces 9. Advanced Contract Programming with Interfaces 10. Maximization of Code Reuse with Generics 11. Advanced Generics 12. Object-Oriented, Functional Programming, and Lambda Expressions 13. Modularity in Java 9 A. Exercise Answers Index

What this book covers

Chapter 1, JShell – A Read-Evaluate-Print-Loop for Java 9, starts our journey towards object-oriented programming with Java 9. We will learn how to launch and work with a new utility introduced with Java 9 that will allow us to easily run Java 9 code snippets and print its results: JShell. This utility will make it easy for us to learn object-oriented programming.

Chapter 2, Real-World Objects to UML Diagrams and Java 9 via JShell, teaches how to recognize objects from real-life situations. We will understand that working with objects makes it easier to write code that is easier to understand and reuse. We will learn how to recognize real-world elements and translate them into the different components of the object-oriented paradigm supported in Java. We will start organizing classes with UML (Unified Modeling Language) diagrams.

Chapter 3, Classes and Instances, shows that classes represent blueprints or templates to generate the objects, which are also known as instances. We will design a few classes that represent blueprints of real-life objects. We will learn about an object's life cycle. We will work with many examples to understand how initialization works. We will declare our first class to generate a blueprint for objects. We will customize its initialization and test its personalized behavior in action with live examples in the JShell. We will understand how the garbage collection works.

Chapter 4, Encapsulation of Data, teaches you the different members of a class in Java 9 and how they are reflected in members of the instances generated from a class. We will work with instance fields, class fields, setters, getters, instance methods, and class methods. We will generate computed properties with setters and getters. We will take advantage of access modifiers to hide data. We will use static fields to create values shared by all the instances of a class.

Chapter 5, Mutable and Immutable Classes, introduces the differences between mutating and non-mutating objects. First, we will create a mutable class, and then we will build an immutable version of this class. We will learn the advantages of non-mutating objects when writing concurrent code.

Chapter 6, Inheritance, Abstraction, Extension, and Specialization, discusses how to take advantage of simple inheritance to specialize or extend a base class. We will design many classes from top to bottom and we will use chained constructors. We will use UML diagrams to design classes that inherit from another class. We will code the classes in the interactive JShell. We will override and overload methods. We will run code to understand how all the things we code work.

Chapter 7, Members Inheritance and Polymorphism, teaches you how to control whether subclasses can or cannot override members. We will take advantage of one of the most exciting object-oriented features: polymorphism. We will take advantage of JShell to easily understand typecasting. We will declare methods that perform operations with instances of classes.

Chapter 8, Contract Programming with Interfaces, introduces how interfaces work in combination with classes in Java 9. The only way to have multiple inheritance in Java 9 is through the usage of interfaces. We will learn about the declaration and combination of multiple blueprints to generate a single instance. We will declare interfaces with different types of requirements. Then, we will declare many classes that implement the created interfaces. We will combine interfaces with classes to take advantage of multiple inheritance in Java 9. We will combine inheritance for interfaces and inheritance for classes.

Chapter 9, Advanced Contract Programming with Interfaces, dives deeper in to contract programming with interfaces. We will work with methods that receive interfaces as arguments. We will understand how downcasting works with interfaces and classes and we will treat instances of an interface type as a different subclass. JShell will allow us to easily understand the complexities of typecasting and downcasting. We will work with more complex scenarios in which we will combine class inheritance with interface inheritance.

Chapter 10, Maximization of Code Reuse with Generics, introduces you to working with parametric polymorphism. We will learn how to maximize code reuse by writing code capable of working with objects of different types, that is, instances of classes that implement specific interfaces or whose class hierarchy includes specific superclasses. We will work with interfaces and generics. We will create a class that works with a constrained generic type. We will use a generic class for multiple types, thanks to generics.

Chapter 11, Advanced Generics, dives deeper in parametric polymorphism. We will declare a class that works with two constrained generic types. We will use a generic class with two generic type parameters in JShell. We will generalize existing classes by taking advantage of generics in Java 9.

Chapter 12, Object-Oriented, Functional Programming, and Lambda Expressions, discusses that functions are first-class citizens in Java 9. We will work with functional interfaces within classes. We will use many functional programming features included in Java 9 and combine them with everything we learned in the previous chapters about object-oriented programming. This way, we will be able to use the best of both worlds. We will analyze the differences between the imperative and functional programming approach for many algorithms. We will take advantage of lambda expressions and combine map operations with reduce.

Chapter 13, Modularity in Java 9, puts together all the pieces of the object-oriented puzzle. We will refactor existing code to take advantage of object-oriented programming. We will understand the usage of modular source code in Java 9. We will work with modules to create a new Java 9 solution, organize object-oriented code with the new modularity in Java 9, and learn many techniques of debuggingobject-oriented code.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image