O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Learning Modern Java: A Crash Course Using Java 8

Video Description

17+ Hours of Video Instruction

Java is the world’s most popular and widely applied programming language, but it is large, complex, and sometimes difficult to get started with. These LiveLessons supply a practical, hands-on introduction to programming with Java 8, the latest version of the language.

The course provides thorough coverage of the foundational Java topics: basic syntax, object-oriented programming, handling exceptions, core data structures, and generic types. It also gives fast-moving coverage of some of the most important libraries: concurrent programming with Java threads, parallel programming with fork/join, network programming, file I/O, and serialization. Finally, it gives detailed explanation of the syntax and usage of lambda expressions and streams, the most important new features in Java 8.

In each section, it gives details on the most important topics, surveys more advanced or lesser-used topics, stresses best practices, and provides plenty of working examples.

If you are new to Java and want to quickly learn the full range of Java programming, but in the context of the latest version (Java 8), continue on: you are in the right place. If, however, you are already comfortable with previous Java versions and want to learn only the new Java 8 features, see Java 8 Lambda Expressions and Streams instead.


In these LiveLessons, expert Java developer, instructor, and author Marty Hall gives a crash course on Java programming. This fast-moving video series is aimed at developers who have used other languages, but who have little or no Java experience.

The first section looks at installing Java and Eclipse, making projects, and understanding loops, conditionals, and other basic Java syntax.

The second section covers object-oriented programming using the Java 8 style. Topics include classes, methods, constructors, interfaces, abstract classes, enums, and lots of guidance on style and best OOP practices.

The third section looks at exception handling, lists and maps, generic types, printf, inner classes, and unit testing with JUnit.

The fourth section looks at asynchronous event handling, concurrent programming with Java threads, and parallel programming using Java’s fork/join framework.

The fifth section looks at the syntax and usage of lambda expressions and streams, with particular emphasis on best practices and the use of parallel streams.

The final section looks at file and network I/O: Java 8 stream-based file reading, network clients, network servers, and serialization.

Please visit http://courses.coreservlets.com/Course-Materials/java.html for the LiveLessons Web site. This site contains complete source code for all examples in the video, as well as exercises and exercise solutions for each topic.

Finally, you can contact the author directly at hall@coreservlets.com with questions or suggestions, or to inquire about customized training courses on Java EE and JavaScript topics to be held onsite at your organization.

The source code repository for this LiveLesson can be downloaded from http://courses.coreservlets.com/Course-Materials/java.html.

About the Instructor

Marty Hall is president of coreservlets.com, a training and consulting company focusing on server-side Java technology, Android development, and Rich Internet Apps with Ajax. In addition to long Java development and consulting experience, Marty has an extensive background in teaching and training, having given training courses on Java 8, JSF 2, PrimeFaces, Android, Ajax/jQuery, and other Java EE topics in dozens of US venues and nine other countries.
A popular and entertaining speaker, Marty has also spoken at conferences and user groups around the world, including Comdex, the Web 2.0 Expo, and five times at JavaOne. Marty is also adjunct faculty in the Johns Hopkins University part-time graduate program in Computer Science, where he directs the Java and Web-related concentration areas.
Marty Hall is also the lead author of six popular Java EE books from Pearson, including Core Servlets and JSP, and is the co-author of the upcoming JSF 2.3 edition of Core JSF.
You can see more details on Marty's bio page:

Skill Level

  • Beginner to intermediate

What You Will Learn

  • Installing Java
  • Installing and using the Eclipse development environment
  • Loops and conditionals
  • Strings, arrays, and other basic Java syntax
  • Classes
  • Instance variables (data members, fields)
  • Methods (member functions)
  • Overloading
  • Inheritance
  • OOP best practices
  • Use of JavaDoc
  • Encapsulation
  • Interfaces using the Java 8 style
  • Abstract classes
  • Enums
  • The toString method
  • Try/catch blocks
  • The @Override annotation
  • Lists and maps
  • Making your own methods and classes that support generic types
  • printf
  • The Arrays utility class
  • Unit testing with JUnit
  • Asynchronous event handling
  • Inner classes
  • Concurrent programming with Java threads
  • Recognizing and dealing with race conditions
  • Parallel programming with the Java fork/join framework
  • Best practices for parallel applications
  • Lambda expressions
  • Method references
  • Lambda building blocks in the java.util.function package
  • Methods that return functions
  • Java 8 streams
  • Creating streams from lists, arrays, and individual values
  • Outputting streams as lists or arrays
  • Core stream methods
  • The new Optional class
  • Lazy evaluation and short-circuit stream operations
  • Streams specialized for numbers
  • Reduction operations
  • Parallel streams
  • Infinite (unbounded) streams
  • Grouping and partitioning stream elements
  • Java 8 stream-based file I/O
  • Network programming: clients
  • Network programming: servers
  • Multithreaded network servers
  • Object serialization

Who Should Take This Course

  • This LiveLessons course is aimed at developers who have at least moderate experience with other programming languages and want to learn Java as quickly as possible. The course moves too fast for first-time programmers. If you are already comfortable with previous Java versions and only want to learn the new Java 8 features, see Java 8 Lambda Expressions and Streams instead of this LiveLesson.

Course Requirements

  • Familiarity with fundamental programming concepts
  • At least moderate experience in programming with another language: C, C++, C#, Objective-C, Python, Perl, Ruby, or JavaScript preferred
  • No prior Java experience is required

Lesson Descriptions

Lesson 1 shows you where to get the Java development kit and the official API documentation, and how to create and execute Java programs in the Eclipse development environment.

Lesson 2 covers basic Java syntax: the main method, strings, loops, arrays, conditional statements, and basic mathematical operations.

Lesson 3 is the first of three lessons on object-oriented programming. If you have never used an object-oriented language before, then this lesson and the next are the most important two lessons in the entire LiveLesson course. OOP is the core programming strategy in Java.
This lesson covers four specific OOP topics: object-oriented terminology and conventions, instance variables, methods, and constructors.

Lesson 4 builds on the techniques from Lesson 3 by adding in three more capabilities: overloading, inheritance, and the toString method. More importantly, it discusses two programming strategies for making your code flexible and reusable: encapsulation and the use of JavaDoc.

Lesson 5 continues to flesh out OOP best practices covering three features in depth: abstract classes, interfaces, and enums. It also summarizes a number of other related advanced topics.

Lesson 6 covers Java applets and simple drawing techniques. This lesson is meant to introduce general topics like the @Override annotation, life-cycle methods, import statements, background threads, and try/catch blocks. Once you know some simple graphics, programming exercises are more interesting.

Lesson 7 introduces two very important data structures: lists and maps. It also explains how to create methods and classes that support generic types. In addition, it summarizes several useful classes and methods: the Arrays utility class, printf, varargs, and StringBuilder.

Lesson 8 shows you how to test the methods that you write using the JUnit testing framework.

Lesson 9 compares and contrasts four different techniques for handling asynchronous keyboard events: entirely separate classes, having the main class implement the appropriate interface, named inner classes, and anonymous inner classes.

Lesson 10 shows you how to perform concurrent programming using the Java threading framework. It first explains the difference between Java's concurrent and parallel programming frameworks. It then shows the basic approach, gives four variations on the theme, and discusses how to avoid the dreaded race conditions.

Lesson 11 shows you how to perform parallel programming using the Java fork/join framework. In addition to showing the techniques and showing examples, this lesson emphasizes the importance of two tasks:
   Verifying that the serial and parallel versions give the same answer
   Evaluating whether the parallel approach yields superior performance

Lesson 12 is the first of four lessons on lambda expressions. Lambdas are Java's way of representing functions. The lesson introduces lambda expressions and illustrates how their use can make your code more flexible and reusable. The lesson closes with two examples of applications that would be difficult and cumbersome without lambdas but which are relatively simple and short with them. The first is a numerical integration routine, and the second is a reusable tool for collecting performance-timing results.

Lesson 13 covers four topics: the @FunctionalInterface annotation, Method references, Lambda variable scoping rules, and the rules regarding effectively final local variables. The lesson shows you how the use of @FunctionalInterface will improve the internal implementation of the previous numerical-integration and timing applications and how method references will make it simpler to use the numerical integration code.

Lesson 14 looks at the pre-built functions in the java.util.function package. The lesson starts with the simply-typed versions and shows how using one of them can shorten our numerical-integration code. It then looks at five generically typed versions: Predicate, Function, Consumer, Supplier, and BinaryOperator. Most Java developers are not used to thinking about functional programming, so this lesson shows how applying functions can make certain applications shorter, simpler, easier to maintain, and more reusable.

Lesson 15 discusses two features of Java interfaces: default methods and static methods. It then uses this idea to improve the previous application that collected timing information. The second half of the lesson illustrates the power that comes from having methods that return lambdas, known as higher order functions.

Lesson 16 is the first of three lessons on streams. It provides an overview of streams and explains their benefits. It then shows you how to create streams and output them into standard Java. It also explains data structures and four of the most important stream methods: forEach, filter, map, and findFirst. The lesson closes with a discussion of lazy evaluation and shows you how it can dramatically improve data processing performance.

Lesson 17 starts out by discussing IntStream and DoubleStream, which are specializations of Streams for dealing with numbers. It then looks in great detail at reduction operations: operations that combine stream values to produce a single result. The lesson starts out with simple ones like min, max, and sum, and then finishes with the general-purpose reduce method. Finally, it discusses other stream methods, such as limit, skip, sorted, and anyMatch.

Lesson 18 starts off by looking at fancy ways to output, partition, or group streams. It then explains how to use parallel streams one of the most powerful stream features and gives a number of examples where parallel streams do or do not work effectively. The lesson closes with an explanation of so-called "infinite" streams: streams that have no preset size, but rather use a generator function to build the elements as they are needed.

Lesson 19 looks at File I/O. It starts by explaining both file reading and file writing, but in particular, it shows how applying the power of streams can dramatically simplify reading and processing files and folders. Specifically, it illustrates why the new Files.lines method is such a huge improvement over alternatives available in earlier Java versions.

Lesson 20 looks at building Java clients that talk to network servers. Along the way, it demonstrates techniques for parsing the strings that are retrieved from the servers. The lesson also summarizes how HTTP (Web) servers operate.

Lesson 21 looks at building Java servers that accept incoming socket connections and shows how (and why) to make these servers multithreaded. It illustrates the techniques by developing a simple HTTP server that can be invoked from an ordinary Web browser.

About LiveLessons Video Training The LiveLessons Video Training series publishes hundreds of hands-on, expert-led video tutorials covering a wide selection of technology topics designed to teach you the skills you need to succeed. This professional and personal technology video series features world-leading author instructors published by your trusted technology brands: Addison-Wesley, Cisco Press, IBM Press, Pearson IT Certification, Prentice Hall, Sams, and Que. Topics include IT certification, programming, Web development, mobile development, home and office technologies, business and management, and more. View all LiveLessons on InformIT at http://www.informit.com/livelessons.

Table of Contents

  1. Introduction
    1. Learning Modern Java: Introduction 00:04:16
  2. Lesson 1: Java with Eclipse: Setup and Getting Started
    1. Topics 00:00:23
    2. 1.1 Installing Java 00:11:34
    3. 1.2 Installing and Using Eclipse 00:09:38
    4. Summary 00:01:35
  3. Lesson 2: Basic Java Syntax
    1. Topics 00:00:19
    2. 2.1 Setup, Execution, and Most Basic Syntax 00:04:19
    3. 2.2 The + Operator, Array Basics, and Command Line Args 00:07:00
    4. 2.3 Loops 00:05:22
    5. 2.4 Class Structure and Formatting 00:06:16
    6. 2.5 Conditionals 00:04:08
    7. 2.6 Strings 00:01:54
    8. 2.7 More on Arrays 00:09:22
    9. 2.8 Math Routines 00:07:00
    10. 2.9 Reading Input 00:05:22
    11. Summary 00:02:44
  4. Lesson 3: Basic Object-Oriented Programming in Java
    1. Topics 00:00:38
    2. 3.1 Overview 00:02:32
    3. 3.2 Basics 00:04:41
    4. 3.3 Instance Variables 00:07:50
    5. 3.4 Methods 00:12:40
    6. 3.5 Constructors 00:13:17
    7. 3.6 Interactive Example: Person Class 00:14:02
    8. Summary 00:01:41
  5. Lesson 4: Object-Oriented Programming in Java: More Capabilities
    1. Topics 00:00:32
    2. 4.1 Overloading 00:04:51
    3. 4.2 OOP Best Practices: Encapsulation and JavaDoc 00:32:30
    4. 4.3 Inheritance 00:08:19
    5. 4.4 Inheritance Example: Person Class 00:08:08
    6. 4.5 The toString Method 00:01:41
    7. Summary 00:02:02
  6. Lesson 5: Object-Oriented Programming in Java: Advanced Capabilities
    1. Topics 00:00:28
    2. 5.1 Sample Problem 00:01:05
    3. 5.2 Attempted Problem Solutions 00:09:23
    4. 5.3 Abstract Classes 00:05:57
    5. 5.4 Interfaces 00:07:48
    6. 5.5 @Override 00:05:27
    7. 5.6 Visibility Modifiers 00:05:48
    8. 5.7 Enums 00:07:23
    9. 5.8 JavaDoc Options 00:05:25
    10. 5.9 The Classpath 00:02:00
    11. Summary 00:02:09
  7. Lesson 6: Applets and Basic Graphics
    1. Topics 00:00:28
    2. 6.1 Motivation 00:02:01
    3. 6.2 Security Restrictions 00:02:53
    4. 6.3 Basic Applet Structure 00:08:33
    5. 6.4 Drawing in Applets: Basics 00:06:27
    6. 6.5 The Value of @Override 00:02:15
    7. 6.6 Applet Life Cycle Methods 00:02:18
    8. 6.7 Other Applet Methods 00:02:54
    9. 6.8 Attributes of the HTML Applet Tag 00:02:12
    10. 6.9 Applet Parameters: Letting the HTML Author Supply Data 00:06:06
    11. 6.10 Drawing in Applets: More Details 00:03:54
    12. 6.11 Loading and Drawing Images 00:07:13
    13. 6.12 Basic Try/Catch Blocks 00:04:32
    14. Summary 00:01:46
  8. Lesson 7: More Syntax and Utilities
    1. Topics 00:00:28
    2. 7.1 Lists 00:14:08
    3. 7.2 List Operation Performance 00:09:37
    4. 7.3 Using Generic Types 00:05:00
    5. 7.4 Autoboxing 00:03:52
    6. 7.5 Maps 00:06:28
    7. 7.6 Building Genericized Methods and Classes 00:07:36
    8. 7.7 The Arrays Utility Class 00:04:02
    9. 7.8 printf 00:10:30
    10. 7.9 Varargs 00:02:57
    11. 7.10 StringBuilder 00:08:52
    12. Summary 00:02:13
  9. Lesson 8: Unit Testing with JUnit: A Very Brief Introduction
    1. Topics 00:00:15
    2. 8.1 Static Imports 00:01:39
    3. 8.2 JUnit Overview 00:06:16
    4. 8.3 Modern Approach 00:10:17
    5. 8.4 Traditional Approach 00:03:00
    6. Summary 00:01:29
  10. Lesson 9: Asynchronous Event Handling
    1. Topics 00:00:37
    2. 9.1 Overview 00:02:53
    3. 9.2 Using Seperate Listener Classes: Basics 00:02:38
    4. 9.3 Using Seperate Listener Classes: Drawing 00:05:45
    5. 9.4 Implementing a Listener Interface 00:04:59
    6. 9.5 Using Named Inner Classes 00:04:13
    7. 9.6 Using Anonymous Inner Classes 00:04:42
    8. 9.7 Preview: Using Java 8 Lambdas 00:03:09
    9. Summary 00:04:57
  11. Lesson 10: Multithreaded Programming in Java
    1. Topics 00:00:28
    2. 10.1 Overview 00:11:15
    3. 10.2 Basic Steps for Concurrent Programming 00:05:07
    4. 10.3 Approach One: Separate Class that Implements Runnable 00:09:42
    5. 10.4 Approach Two: Main App Implements Runnable 00:06:33
    6. 10.5 Approach Three: Inner Class that Implements Runnable 00:05:07
    7. 10.6 Preview of Approach Four: Lambda Expressions 00:00:39
    8. 10.7 Summary of Approaches with Pros and Cons 00:02:03
    9. 10.8 Making a Reusable Multithreaded Server: Template 00:02:29
    10. 10.9 Race Conditions: Problem 00:05:22
    11. 10.10 Race Conditions: Solution 00:06:46
    12. 10.11 Helpful Thread-Related Methods 00:05:16
    13. 10.12 Brief Summary of Advanced Topics 00:06:59
    14. 10.13 Tricky Synchronization Problem 00:05:35
    15. Summary 00:01:29
  12. Lesson 11: Parallel Programming with the Fork/Join Framework
    1. Topics 00:00:32
    2. 11.1 Overview 00:02:31
    3. 11.2 General Fork/Join Approach 00:07:22
    4. 11.3 Aside: Reusable Timing Code 00:04:22
    5. 11.4 Summing Large Array of Doubles: Version 1 00:04:38
    6. 11.5 Summing Large Array of Doubles Version 1: Verification Step 00:08:50
    7. 11.6 Making Reusable Parallel Array Processor 00:07:14
    8. 11.7 Summing Large Array of Doubles: Version 2 00:03:39
    9. 11.8 Computing Minimum of Expensive Operation 00:05:46
    10. 11.9 Generating Large Prime Numbers 00:07:16
    11. Summary 00:03:07
  13. Lesson 12: Lambda Expressions—Part 1: Basics
    1. Topics 00:00:37
    2. 12.1 Motivation and Overview 00:10:58
    3. 12.2 Lambdas: Most Basic Form 00:10:55
    4. 12.3 Type Inferencing 00:04:44
    5. 12.4 Expression for Body: Implied Return Values 00:08:25
    6. 12.5 Omitting Parens 00:03:43
    7. 12.6Summary: Making Lambdas More Succinct 00:03:58
    8. 12.7 Example: Numerical Integration 00:05:15
    9. 12.8 Making a Reusable Timing Utility 00:04:38
    10. 12.9 A Few More Samples 00:01:48
    11. Summary 00:03:53
  14. Lesson 13: Lambda Expressions in Java 8—Part 2
    1. Topics 00:00:40
    2. 13.1 The @FunctionalInterface Annotation 00:05:19
    3. 13.2 Method References 00:24:08
    4. 13.3 Lambda Variable Scoping in Lambdas 00:04:39
    5. 13.4 Effectively Final Local Variables 00:05:20
    6. Summary 00:02:13
  15. Lesson 14: Lambda Expressions in Java 8—Part 3: Lambda Building Blocks in java.util.function
    1. Topics 00:00:46
    2. 14.1 Overview: Lambda Building Blocks 00:08:47
    3. 14.2 Simply-Typed Building Blocks 00:04:58
    4. 14.3 Generic Building Blocks: Predicate 00:04:13
    5. 14.4 Generic Building Blocks: Function 00:08:48
    6. 14.5 Other Generic Building Blocks 00:08:13
    7. Summary 00:01:55
  16. Lesson 15: Lambda Expressions in Java 8—Part 4
    1. Topics 00:00:38
    2. 15.1 Java 8 Interfaces: Static Methods 00:05:26
    3. 15.2 Java 8 Interfaces: Default Methods 00:05:39
    4. 15.3 Resolving Conflicts with Default Methods 00:04:03
    5. 15.4 Higher Order Functions: Methods that Return Functions 00:02:19
    6. 15.5 Higher Order Functions in Predicate 00:04:46
    7. 15.6 Higher Order Functions in Function 00:07:29
    8. 15.7 Higher Order Functions in Consumer 00:03:18
    9. 15.8 Higher Order Functions in Your Own Code 00:04:18
    10. Summary 00:04:40
  17. Lesson 16: Streams in Java 8—Part 1
    1. Topics 00:00:37
    2. 16.1 Overview of Streams 00:11:28
    3. 16.2 Getting Standard Data Structures into and out of Streams 00:11:38
    4. 16.3 Core Stream Methods: Overview 00:06:22
    5. 16.4 forEach: Calling a Lambda on Each Element of a Stream 00:09:14
    6. 16.5 map: Transforming a Stream by Passing Each Element through a Function 00:07:34
    7. 16.6 filter: Keeping Only the Elements that Pass a Predicate 00:04:06
    8. 16.7 findFirst: Returning the First Element of a Stream while Short-Circuiting Earlier Operations 00:10:45
    9. 16.8 Lazy Evaluation 00:09:07
    10. Summary 00:02:33
  18. Lesson 17: Streams in Java 8—Part 2
    1. Topics 00:00:40
    2. 17.1 Operations that Limit the Stream Size: limit, skip 00:02:17
    3. 17.2 Operations that Use Comparisons: sorted, min, max, distinct 00:05:40
    4. 17.3 Operations that Check Matches: allMatch, anyMatch, noneMatch, count 00:02:38
    5. 17.4 Number-Specialized Streams 00:08:00
    6. 17.5 The reduce Method and Related Reduction Operations 00:09:00
    7. Summary 00:02:20
  19. Lesson 18: Streams in Java 8—Part 3
    1. Topics 00:00:46
    2. 18.1 Grouping Stream Elements: Fancy Uses of collect 00:10:09
    3. 18.2 Parallel Streams 00:14:31
    4. 18.3 Infinite (Unbounded On-the-Fly) Streams 00:16:25
    5. Summary 00:02:02
  20. Lesson 19: Simplified File I/O: Applying the Power of Streams
    1. Topics 00:00:31
    2. 19.1 More on try/catch Blocks 00:06:54
    3. 19.2 Paths 00:02:44
    4. 19.3 Simple File Reading 00:09:00
    5. 19.4 File Reading Examples 00:12:18
    6. 19.5 Simple File Writing 00:04:29
    7. 19.6 Exploring Folders 00:04:09
    8. 19.7 Faster and More Flexible File Writing 00:02:03
    9. Summary 00:02:49
  21. Lesson 20: Network Programming: Clients
    1. Topics 00:00:23
    2. 20.1 Overview 00:08:55
    3. 20.2 Basic Steps for a Client to Connect to a Server 00:10:08
    4. 20.3 A Reusable Network Client Base Class 00:07:11
    5. 20.4 Aside: String Formatting and Parsing 00:14:21
    6. 20.5 Problems with Blocking IO 00:07:44
    7. 20.6 Talking to Web Servers: General 00:03:30
    8. 20.7 Talking to Web Servers: A Java Client 00:10:38
    9. Summary 00:02:36
  22. Lesson 21: Network Programming: Servers
    1. Topics 00:00:26
    2. 21.1 Basics 00:07:21
    3. 21.2 Simple Warmup: A Single-Threaded Server 00:06:53
    4. 21.3 A Base Class for a Multithreaded Server 00:02:33
    5. 21.4 A Simple Multithreaded HTTP Server 00:08:51
    6. Summary 00:02:33
  23. Lesson 22: Serialization: Sending Complex Java Data Structures to Files or over the Network
    1. Topics 00:00:25
    2. 22.1 Overview 00:12:24
    3. 22.2 Sending Data 00:03:17
    4. 22.3 Receiving Data 00:03:22
    5. 22.4 Example: Sending Entire Window to File or Socket 00:09:40
    6. Summary 00:02:24
  24. Summary
    1. Learning Modern Java: Summary 00:00:51