Interactive Java & JShell: Writing Java Programs with the Interactive JShell

Java    |    Beginner
  • 13 videos | 1h 55m 58s
  • Includes Assessment
  • Earns a Badge
Rating 4.4 of 25 users Rating 4.4 of 25 users (25)
Most Java developers use a full-fledged IDE to build complex Java applications. However, there will be many occasions where you need to test snippets of Java code quickly or build a small script without the overhead of having to develop, compile, and execute programs. This is where JShell comes in. In this course, practice using JShell to run snippets of Java code and get immediate results. Use various features of JShell, from the declaration of functions, available feedback modes, and the auto-complete feature. Define a class in various iterations until you're satisfied with its behavior. Then, compile several snippets of previously run Java code to build a JShell script that reads data from one file, transforms it, and writes it into another file. When you're done with this course, you'll be able to use JShell to write your Java programs.

WHAT YOU WILL LEARN

  • Discover the key concepts covered in this course
    Set up jshell and execute basic java commands in the interactive environment
    Create and invoke functions in the jshell
    Define a function that includes a forward reference and recognize the limitations of such methods
    Adjust feedback modes to regulate the output produced after running code snippets
    Use the auto-complete feature to automatically fill in code details
    Recognize how imports work in jshell and how objects can be instantiated
  • Create and use classes or types in jshell in order to work with bespoke entities
    Describe how objects are affected when the classes they are built out of are modified
    Read in data from a csv file into a jshell program
    Export and save data in your program out to a file
    Gather together snippets of previously executed code to create a jshell script
    Summarize the key concepts covered in this course

IN THIS COURSE

  • 2m 17s
    In this video, you’ll learn more about your instructor and this course. You’ll learn how JShell allows you to run Java code and get immediate results. This instant feedback can help you confirm your code's behavior and speed up your development work. You’ll also explore features of JShell like the declaration of functions and feedback modes available to the auto-complete feature. You'll then move on to defining a class and do this in various iterations. FREE ACCESS
  • 12m 19s
    In this video, you’ll learn more about the use of JShell. You’ll learn Jshell is an interactive tool that makes it easy to write Java programs in an iterative manner. That is, you can write bits of Java code, execute it, and then view the results immediately before moving on and building up on your code base. JShell provides a repl environment for Java Programmers, where repl is short for read, evaluate, print, loop. FREE ACCESS
  • Locked
    3.  Defining and Calling Functions in JShell
    12m 57s
    In this video, you’ll learn JShell function definitions. You’ll begin with one of the simplest functions. It calculates the sum of two numbers and then returns it. This is a function called returnSum whose arguments are two integers, x and y. Its return type is int. And in the function body, you have is return x + y. This expression inside the body is terminated by a semicolon. Semicolons are required inside the function bodies. FREE ACCESS
  • Locked
    4.  Defining Functions Referencing External Variables
    7m 24s
    In this video, you’ll learn more about functions, but while doing so, you’ll also explore a few additional concepts. These include references to variables outside of the function definition. First, you’ll learn a function called usdToEUR. This introduces you to an example that you’ll use repeatedly throughout this learning path. FREE ACCESS
  • Locked
    5.  Adjusting Feedback Modes in JShell
    11m 51s
    In this video, you’ll learn more about the degree of instant feedback you’ll get in JShell. You’ll learn this is something that can be controlled. This is where the different Feedback Modes in JShell come into the picture. In this demo, you’ll view the value assigned to the variable EUR_USD. You’ll see you can simply type it in the Shell and then hit Enter. The output immediately confirms what the value is. FREE ACCESS
  • Locked
    6.  Using the Auto-complete Feature in JShell
    8m 19s
    In this video, you’ll learn more about JShell's Auto-complete Feature. You’ll watch a demo on this. First, you’ll type in the name of one of the functions you’ve created, usdToEUR. You’ll open up a parenthesis. Once you’ve specified the function name and an open parenthesis, so you can hit the Tab button on the keyboard to view the auto-complete options. FREE ACCESS
  • Locked
    7.  Working with Different JShell Features
    10m 27s
    In this video, you’ll learn JShell offers an environment to write code, execute code for quick feedback, and then iteratively build upon your code base. So far, you’ve covered the use of variables as well as functions, now you’ll touch on the use of Java Arrays. You’ll learn more about control structures, such as for loops and other Java-related programming features when using JShell. FREE ACCESS
  • Locked
    8.  Working with User-defined Types in JShell
    10m 33s
    In this video, you’ll learn the most common way of building Java applications is to use an IDE such as IntelliJ or Eclipse. However, if you want to develop a quick Java program to perform a few transformations, JShell offers a much better interface. It allows you to get quick feedback on your work and quickly develop a prototype and convert it to a script. FREE ACCESS
  • Locked
    9.  Updating User-defined Types in JShell
    5m 14s
    In this video, you’ll continue building upon the Product class created in the previous course. Currently, you have five different fields for your Product as well as a constructor, which takes in five arguments where each of the fields can be assigned a value. To view the default representation of an object in the form of a String, you’ll look at the output of the vars command, specifically the representation of the zofMonitor object. FREE ACCESS
  • Locked
    10.  Loading Data from a File into JShell
    12m 58s
    In this video, you’ll learn how to load data from a file into JShell. You now have a Product class you can work with. You’ve also tested the Product class by creating two objects of that class. You’ll now take a look at the file needed to read the product information. You’ll see the csv file onscreen. This is called products.csv and each line represents a single Product. This is a comma-separated value file. FREE ACCESS
  • Locked
    11.  Writing Data to a File Using JShell
    8m 7s
    In this video, you’ll see there’s Product information available inside the csv file. You’ll read from that file, load the Product details into objects of type Product, and then apply some transformations before writing the transformed data into another file. In past demos, you’ve read from the csv file, loaded the information into Product objects, and now you’ll apply transformations to the data and then write to a file. FREE ACCESS
  • Locked
    12.  Building and Running JShell Scripts
    10m 45s
    In this video, you’ll combine all that you’ve done in previous demos into a single script. For this demo, there are two files needed, and those are in the directory. You’ll head to your home directory /Project/Skillsoft. Running an ls shows you there are two files available. The first is the JShell script, which was created using the different snippets you’ve previously explored. This file has the extension jsh representing a JShell script. FREE ACCESS
  • Locked
    13.  Course Summary
    2m 48s
    In this video, you’ll summarize what you’ve learned in the course. You started by opening the JShell environment and learned how it can be used to interactively execute chunks of Java code. You learned JShell gives instant feedback in the form of output for the individual snippets. You created and viewed various variables, defined and invoked functions, and explored how they can reference external variables. You then learned about feedback modes. FREE ACCESS

EARN A DIGITAL BADGE WHEN YOU COMPLETE THIS COURSE

Skillsoft is providing you the opportunity to earn a digital badge upon successful completion on some of our courses, which can be shared on any social network or business platform.

Digital badges are yours to keep, forever.

YOU MIGHT ALSO LIKE

Rating 4.6 of 25 users Rating 4.6 of 25 users (25)
Rating 4.5 of 75 users Rating 4.5 of 75 users (75)
Rating 4.6 of 37 users Rating 4.6 of 37 users (37)