Java 9 with JShell
eBook - ePub

Java 9 with JShell

Gaston C. Hillar

Share book
  1. 408 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Java 9 with JShell

Gaston C. Hillar

Book details
Book preview
Table of contents
Citations

About This Book

Explore Java 9 with JShell and UMLAbout This Book• A full account of Java 9's new features• This tutorial emphasises fluency using JShell exercises• Get a thorough introduction to contract programming code reuse via Java generics• Learn how to use the new module system• How to use proper functional programming style inside Java 9Who This Book Is ForThis book can be understood by anyone who is a graduate of computer science or someone who has just begun working as a software engineer. Basically, an understanding of an object-oriented programming language like Python, C++ or indeed, an earlier Java version is sufficient. It would be helpful to have participated in the full product cycle of a software engineering project.What You Will Learn• Engage with object-oriented programming in Java 9, starting with code snippets in JShell• Optimize your code, applying functional programming features• Discover the advantages of modularity• Become very proficient at using JShell itself• Learn the new approach to Java programming, which uses the REPL as a prototyping toolIn DetailThe release of Java 9 has brought many subtle and not-so-subtle changes to the way in which Java programmers approach their code. The most important ones are definitely the availability of a REPL, known as JShell, which will make experiments and prototyping much more straightforward than the old IDE-based project-led approach. Another, more subtle change can be seen in the module system, which will lead to more modularized, maintainable code. The techniques to take full advantage of object-oriented code, functional programming and the new modularity features in Java 9 form the main subjects of this book.Each chapter will add to the full picture of Java 9 programming starting out with classes and instances and ending with generics and modularity in Java.Style and approachYou will learn by doing: using JShell as their prototyping environment, you will take full advantage of the new features of Java 9, in particular the full module system and the functional features of Java 9.. There won't be any theory, only small and medium-sized exampled enabling the reader to use the new Java features in professional software engineering projects.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Java 9 with JShell an online PDF/ePUB?
Yes, you can access Java 9 with JShell by Gaston C. Hillar in PDF and/or ePUB format, as well as other popular books in Informatica & Programmazione in Java. We have over one million books available in our catalogue for you to explore.

Information

Year
2017
ISBN
9781787285194

Java 9 with JShell


Table of Contents

Java 9 with JShell
Credits
About the Author
Acknowledgement
About the Reviewer
www.PacktPub.com
eBooks, discount offers, and more
Why subscribe?
Customer Feedback
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. JShell – A Read-Evaluate-Print-Loop for Java 9
Getting ready for our journey toward OOP with Java 9
Installing the required software on Windows, macOS, or Linux
Understanding the benefits of working with a REPL
Checking default imports and using auto-complete features
Running Java 9 code in JShell
Evaluating expressions
Working with variables, methods, and sources
Editing the source code in our favorite external code editor
Loading source code
Test your knowledge
Summary
2. Real-World Objects to UML Diagrams and Java 9 via JShell
Identifying objects from applications requirements
Capturing real-world objects
Generating classes to create objects
Recognizing variables and constants
Identifying actions to create methods
Organizing classes with UML diagrams
Using feedback from domain experts
Test your knowledge
Summary
3. Classes and Instances
Understanding classes and instances in Java 9
Working with object initialization and its customization
Introducing garbage collection
Declaring classes
Customizing constructors and initialization
Understanding how garbage collection works
Creating instances of classes and understanding their scope
Exercises
Exercise 1
Exercise 2
Test your knowledge
Summary
4. Encapsulation of Data
Understanding members composing a class
Declaring immutable fields
Working with setters and getters
Exploring access modifiers in Java 9
Combining setters, getters, and fields
Transforming values with setters and getters
Using static fields to provide class-level values
Using static methods to provide overridable class-level values
Test your knowledge
Summary
5. Mutable and Immutable Classes
Creating mutable classes in Java 9
Working with mutable objects in JShell
Building immutable classes in Java 9
Working with immutable objects in JShell
Understanding the differences between mutating and non-mutating objects
Learning the advantages of non-mutating objects when writing concurrent code
Working with instances of the immutable String class
Creating the immutable version of an existing mutable class
Test your knowledge
Summary
6. Inheritance, Abstraction, Extension, and Specialization
Creating class hierarchies to abstract and specialize behavior
Understanding inheritance
Creating an abstract base class
Declaring classes that inherit from another class
Overriding and overloading methods
Test your knowledge
Summary
7. Members Inheritance and Polymorphism
Creating concrete classes that inherit from abstract superclasses
Understanding polymorphism
Controlling overridability of members in subclasses
Controlling subclassing of classes
Creating methods that work with instances of different subclasses
Test your knowledge
Summary
8. Contract Programming with Interfaces
Understanding how interfaces work in combination with classes
Declaring interfaces
Declaring classes that implement interfaces
Taking advantage of the multiple inheritance of interfaces
Combining class inheritance and interfaces
Test your knowledge
Summary
9. Advanced Contract Programming with Interfaces
Working with methods receiving interfaces as arguments
Downcasting with interfaces and classes
Treating instances of an interface type as a different subclass
Taking advantage of default methods in interfaces in Java 9
Test your knowledge
Summary
10. Maximization of Code Reuse with Generics
Understanding parametric polymorphism, Java 9 generics, and generic code
Declaring an interface to be used as a type constraint
Declaring a class that conforms to multiple interfaces
Declaring subclasses that inherit the implementation of interfaces
Creating exception classes
Declaring a class that works with a constrained generic type
Using a generic class for multiple compatible types
Test your knowledge
Summary
11. Advanced Generics
Creating a new interface to be used as a constraint for a second type parameter
Declaring two classes that implement an interface to work with two type parameters
Declaring a class that works with two constrained generic types
Creating instances of a generic class with two generic type parameters
Test your knowledge
Summary
12. Object-Oriented, Functional Programming, and Lambda Expressions
Understanding functions and methods as first-class citizens
Working with functional interfaces and lambda expressions
Creating a functional version of array filtering
Creating a data repository with generics and interfaces
Filtering collections with complex conditions
Using a map operation to transform values
Combining a map operation with reduce
Chaining many operations with map and reduce
Working with different collectors
Test your knowledge
Summary
13. Modularity in Java 9
Refactoring existing code to take advantage of object-oriented programming
Organizing object-oriented code with the new modularity in Java 9
Creating modular source code
Compiling multiple modules with the Java 9 compiler
Run modularized code with Java 9
Test your knowledge
Summary
A. Exercise Answers
Chapter 1, JShell – A Read-Evaluate-Print-Loop for Java 9
Chapter 2, Real-World Objects to UML Diagrams and Java 9 via JShell
Chapter 3, Classes and Instances
Chapter 4, Encapsulation of Data
Chapter 5, Mutable and Immutable Classes
Chapter 6, Inheritance, Abstraction, Extension, and Specialization
Chapter 7, Members Inheritance and Polymorphism
Chapter 8, Contract Programming with Interfaces
Chapter 9, Advanced Contract Programming with Interfaces
Chapter 10, Maximization of Code Reuse with Generics
Chapter 11, Advanced Generics
Chapter 12, Object-Oriented, Functional Programming, and Lambda Expressions
Chapter 13, Modularity in...

Table of contents