hands-on lab

Coding with Generics and Lambdas

Intermediate
Up to 2h
787
3.7/5
Get guided in a real environmentPractice with a step-by-step scenario in a real, provisioned environment.
Learn and validateUse validations to check your solutions every step of the way.
See resultsTrack your knowledge and monitor your progress.
Lab description

Lab Overview

Being able to code using Java Generics and Lambdas provides you with the ability to create reusable, expressive, and concise Java code.

This lab is designed to deepen your Java Generics and Lambdas knowledge. You will be required to complete the following Java coding exercise:

  • Exercise 1 - DynamicArray: Complete the code required to create a dynamically expanding custom StringArray class. This exercise will leverage unit testing through the use of JUnit to confirm the desired behavior of the custom StringArray class.
  • Exercise 2 - GenericDynamicArray: Complete the code required to generalize the previous exercise, by converting the StringArray class into a generic ObjectArray<T> class. This exercise will leverage unit testing through the use of JUnit to confirm the desired behavior of the custom ObjectArray<T> class.
  • Exercise 3 - Lambda: Complete the code required to use Lambdas in different programming contexts:
    • Sorting using a Comparator
    • Configuring an addActionListener method on a Swing JButton
    • Spawning new threads using the java.lang.Runnable functional interface

Note: Each exercise is supplied with a fully completed solution code for reference when required.

Lab Objectives

Upon completion of this lab, you will be able to:

  • Write reusable Java code through the use of Generics
  • Write Java code that is concise and expressive through the use of Lambdas
  • Understand the benefits of working with Lambdas and Functional Interfaces
  • Run and debug the Java code and examine the results that are printed to the console

You should:

  • Be comfortable with using a browser-based IDE

Lab Environment

This lab will start with the following AWS resources provisioned automatically for you:

  • A single EC2 instance, named ide.java.platform.instance, which will have a public IP address attached. This instance will host a web-based Java IDE (based on the Visual Code editor).

To achieve the lab end state, you will be walked through the process of:

  • Using your local browser, access the web-based Java IDE served from the ide.java.platform.instance
  • Completing the following lab exercises:
    • Exercise 1 -DynamicArray
    • Exercise 2 -GenericDynamicArray
    • Exercise 3 -Lambda

Updates

June 16th, 2018 - Optimized creation of lab resources to reduce the time it takes to access the browser IDE by 60%.

Environment before

Environment after

About the author
Avatar
Jeremy Cook, opens in a new tab
Content Lead Architect
Students
160,752
Labs
82
Courses
106
Learning paths
214

Jeremy is a Content Lead Architect and DevOps SME here at Cloud Academy where he specializes in developing DevOps technical training documentation.

He has a strong background in software engineering, and has been coding with various languages, frameworks, and systems for the past 25+ years. In recent times, Jeremy has been focused on DevOps, Cloud (AWS, Azure, GCP), Security, Kubernetes, and Machine Learning.

Jeremy holds professional certifications for AWS, Azure, GCP, Terraform, Kubernetes (CKA, CKAD, CKS).

Covered topics
Lab steps
Connecting to the Java Web IDE
Exercise 1 - Dynamic Array
Exercise 2 - Generic Dynamic Array
Exercise 3 - Lambdas