Learn more from Oracle University at education.oracle.com Java SE 8 Programming

Learn more from Oracle University at education.oracle.com Java SE 8 Programming Student Guide - Volume I D84838GC10 Edition 1.0 | December 2016 | D87757 Ayushi Gupta (ayushiฺgupta@oracleฺcom) has a non-transferable license to use this Student Guideฺ Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Disclaimer This document contains proprietary information and is protected by copyright and other intellectual property laws. You may copy and print this document solely for your own use in an Oracle training course. The document may not be modified or altered in any way. Except where your use constitutes "fair use" under copyright law, you may not use, share, download, upload, copy, print, display, perform, reproduce, publish, license, post, transmit, or distribute this document in whole or in part without the express authorization of Oracle. The information contained in this document is subject to change without notice. If you find any problems in the document, please report them in writing to: Oracle University, 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not warranted to be error-free. Restricted Rights Notice If this documentation is delivered to the United States Government or anyone using the documentation on behalf of the United States Government, the following notice is applicable: U.S. GOVERNMENT RIGHTS The U.S. Government’s rights to use, modify, reproduce, release, perform, display, or disclose these training materials are restricted by the terms of the applicable Oracle license agreement and/or the applicable U.S. Government contract. Trademark Notice Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. Authors Anjana Shenoy Michael Williams Tom McGinn Peter Fernandez Technical Contributors and Reviewers Pete Daly Sravanti Tatiraju Nick Ristuccia Stuart Marks Hiroshi Hiraga Peter Hall Matthew Slingsby Marcus Hirt Irene Rusman Joanne Sun Marilyn Beck Joe A Boulenouar Editors Aju Kumar Malavika Jinka Arijit Ghosh Anwesha Ray Graphic Designer Divya Thallap Publishers Giri Venugopal Michael Sebastian Veena Narasimhan Ayushi Gupta (ayushiฺgupta@oracleฺcom) has a non-transferable license to use this Student Guideฺ Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ iii Contents 1 Introduction Course Goals 1-2 Course Objectives 1-3 Audience 1-5 Prerequisites 1-6 Class Introductions 1-7 Course Environment 1-8 Java Programs Are Platform-Independent 1-9 Java Technology Product Groups 1-10 Java SE Platform Versions 1-11 Downloading and Installing the JDK 1-12 Java in Server Environments 1-13 The Internet of Things 1-14 The Java Community 1-15 The Java Community Process (JCP) 1-16 OpenJDK 1-17 Oracle Java SE Support 1-18 Additional Resources 1-19 Summary 1-20 2 Java Syntax and Class Review Objectives 2-2 Java Language Review 2-3 Java Class Structure 2-4 A Simple Class 2-5 Java Naming Conventions 2-6 How to Compile and Run 2-7 How to Compile and Run: Example 2-8 Code Blocks 2-9 Primitive Data Types 2-10 Numeric Literals 2-11 Operators 2-12 Logical Operators 2-13 if else Statement 2-14 switch Statement 2-15 Ayushi Gupta (ayushiฺgupta@oracleฺcom) has a non-transferable license to use this Student Guideฺ Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ iv while Loop 2-16 do-while Loop 2-17 for Loop 2-18 Arrays and for-each Loop 2-19 Strings 2-20 String Operations: StringBuilder 2-21 A Simple Java Class: Employee 2-22 Methods 2-23 Creating an Instance of a Class 2-24 Constructors 2-25 package Statement 2-26 import Statements 2-27 Java Is Pass-By-Value 2-29 Pass-By-Value for Object References 2-30 Objects Passed as Parameters 2-31 Garbage Collection 2-32 Summary 2-33 Practice 2-1 Overview: Creating Java Classes 2-34 Quiz 2-35 3 Encapsulation and Subclassing Objectives 3-2 Encapsulation 3-3 Encapsulation: Example 3-4 Encapsulation: Public and Private Access Modifiers 3-5 Encapsulation: Private Data, Public Methods 3-6 Employee Class Refined 3-7 Make Classes as Immutable as Possible 3-8 Method Naming: Best Practices 3-9 Encapsulation: Benefits 3-10 Creating Subclasses 3-11 Subclassing 3-12 Manager Subclass 3-13 Constructors in Subclasses 3-14 Using super 3-15 Constructing a Manager Object 3-16 Overloading Methods 3-17 Overloaded Constructors 3-18 Overloaded Constructors: Example 3-19 Single Inheritance 3-20 Summary 3-21 Ayushi Gupta (ayushiฺgupta@oracleฺcom) has a non-transferable license to use this Student Guideฺ Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ v Practice 3-1 Overview: Creating Subclasses 3-22 Quiz 3-23 4 Overriding Methods, Polymorphism, and Static Classes Objectives 4-2 Using Access Control 4-3 Protected Access Control: Example 4-4 Access Control: Good Practice 4-5 Overriding Methods 4-6 Invoking an Overridden Method 4-8 Virtual Method Invocation 4-9 Accessibility of Overriding Methods 4-10 Applying Polymorphism 4-11 Using the instanceof Keyword 4-13 Overriding Object methods 4-14 Object toString Method 4-15 Object equals Method 4-16 Overriding equals in Employee 4-17 Overriding Object hashCode 4-18 Methods Using Variable Arguments 4-19 Casting Object References 4-21 Upward Casting Rules 4-22 Downward Casting Rules 4-23 static Keyword 4-24 Static Methods 4-25 Using Static Variables and Methods: Example 4-26 Implementing Static Methods 4-27 Calling Static Methods 4-28 Static Variables 4-29 Defining Static Variables 4-30 Using Static Variables 4-31 Static Initializers 4-32 Static Imports 4-33 Design Patterns 4-34 Singleton Pattern 4-35 Singleton: Example 4-36 Immutable Classes 4-37 Example: Creating Immutable class in Java 4-38 Summary 4-39 Practice 4-1 Overview: Overriding Methods and Applying Polymorphism 4-40 Practice 4-2 Overview: Overriding Methods and Applying Polymorphism 4-41 Ayushi Gupta (ayushiฺgupta@oracleฺcom) has a non-transferable license to use this Student Guideฺ Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ vi Practice 4-3 Overview: Applying the Singleton Design Pattern 4-42 Quiz 4-43 5 Abstract and Nested Classes Objectives 5-2 Modeling Business Problems with Classes 5-3 Enabling Generalization 5-4 Identifying the Need for Abstract Classes 5-5 Defining Abstract Classes 5-6 Defining Abstract Methods 5-7 Validating Abstract Classes 5-8 Final Methods 5-9 Final Classes 5-10 Final Variables 5-11 Declaring Final Variables 5-12 Nested Classes 5-13 Example: Member Class 5-14 Enumerations 5-15 Enum Usage 5-16 Complex Enums 5-17 Summary 5-19 Practice 5-1 Overview: Applying the Abstract Keyword 5-20 Practice 5-2 Overview: Using Inner Class As a Helper Class 5-21 Practice 5-3 Overview: Using Java Enumerations 5-22 Quiz 5-23 6 Interfaces and Lambda Expressions Objectives 6-2 Java Interfaces 6-3 A Problem Solved by Interfaces 6-4 CrushedRock Class 6-5 The SalesCalcs Interface 6-6 Adding an Interface 6-7 Interface References 6-8 Interface Reference Usefulness 6-9 Interface Code Flexibility 6-10 default Methods in Interfaces 6-11 default Method: Example 6-12 static Methods in Interfaces 6-13 Constant Fields 6-14 Extending Interfaces 6-15 Ayushi Gupta (ayushiฺgupta@oracleฺcom) has a non-transferable license to use this Student Guideฺ Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ vii Implementing and Extending 6-16 Anonymous Inner Classes 6-17 Anonymous Inner Class: Example 6-18 String Analysis Regular Class 6-19 String Analysis Regular Test Class 6-20 String Analysis Interface: Example 6-21 String Analyzer Interface Test Class 6-22 Encapsulate the for Loop 6-23 String Analysis Test Class with Helper Method 6-24 String Analysis Anonymous Inner Class 6-25 String Analysis Lambda Expression 6-26 Lambda Expression Defined 6-27 What Is a Lambda Expression? 6-28 Lambda Expression Shorthand 6-31 Lambda Expressions as Variables 6-32 Summary 6-33 Practice 6-1: Implementing an Interface 6-34 Practice 6-2: Using Java Interfaces 6-35 Practice 6-3: Creating Lambda Expression 6-36 Quiz 6-37 7 Generics and Collections Objectives 7-2 Topics 7-3 Generics 7-4 Simple Cache Class Without Generics 7-5 Generic Cache Class 7-6 Generics in Action 7-7 Generics with Type Inference Diamond 7-8 Collections 7-9 Collection Types 7-10 Collection Interfaces and Implementation 7-11 List Interface 7-12 ArrayList 7-13 Autoboxing and Unboxing 7-14 ArrayList Without Generics 7-15 Generic ArrayList 7-16 Generic ArrayList: Iteration and Boxing 7-17 Set Interface 7-18 TreeSet: Implementation of Set 7-19 Map Interface 7-20 Ayushi Gupta (ayushiฺgupta@oracleฺcom) has a non-transferable license to use this Student Guideฺ Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ viii Map Types 7-21 TreeMap: Implementation of Map 7-22 Deque Interface 7-23 Stack with Deque: Example 7-24 Ordering Collections 7-25 Comparable: Example 7-26 Comparable Test: Example 7-27 Comparator Interface 7-28 Comparator: Example 7-29 Comparator Test: Example 7-30 Summary 7-31 Practice 7-1 Overview: Counting Part Numbers by Using a HashMap 7-32 Practice 7-2 Overview: Implementing Stack by Using a Deque Object 7-33 Quiz 7-34 8 Collections, Streams, and Filters Objectives 8-2 Collections, Streams, and Filters 8-3 The Person Class 8-4 Person Properties 8-5 Builder Pattern 8-6 Collection Iteration and Lambdas 8-7 RoboCallTest07: Stream and Filter 8-8 RobocallTest08: Stream and Filter Again 8-9 SalesTxn Class 8-10 Java Streams 8-11 The Filter Method 8-12 Method References 8-13 Method Chaining 8-14 Pipeline Defined 8-16 Summary 8-17 Practice Overview 8-18 9 Lambda Built-in Functional Interfaces Objectives 9-2 Built-in Functional Interfaces 9-3 The java.util.function Package 9-4 Example Assumptions 9-5 Predicate 9-6 Predicate: Example 9-7 Consumer 9-8 Ayushi Gupta (ayushiฺgupta@oracleฺcom) has a non-transferable license to use this Student Guideฺ Unauthorized reproduction or distribution prohibitedฺ Copyright© 2018, Oracle and/or its affiliatesฺ ix Consumer: Example 9-9 Function 9-10 Function: Example 9-11 Supplier 9-12 Supplier: Example 9-13 Primitive Interface 9-14 Return a Primitive Type 9-15 Return a Primitive Type: Example 9-16 Process a Primitive Type 9-17 Process Primitive Type: Example 9-18 Binary Types 9-19 Binary Type: Example 9-20 Unary Operator 9-21 UnaryOperator: Example 9-22 Wildcard Generics Review 9-23 Summary 9-24 Practice Overview 9-25 10 Lambda Operations Objectives 10-2 Streams uploads/s1/ guide-for-java.pdf

  • 29
  • 0
  • 0
Afficher les détails des licences
Licence et utilisation
Gratuit pour un usage personnel Attribution requise
Partager
  • Détails
  • Publié le Oct 08, 2022
  • Catégorie Administration
  • Langue French
  • Taille du fichier 4.8570MB