What is the use of the Tab key in JShell in Java 9?


JShell can also provide an auto-completion feature when we partially type the name of an existing class, variable, or method by pressing the Tab key. If an item can't determine from what we entered, then possible options are provided.

Pressing the Tab key in JShell performs one of the following tasks:

  • If no other name matches what we have typed, JShell enters the rest of the name for us.
  • If there are multiple names that begin with the same letters, then JShell displays a list of those names to help what to type next, then type the next letter(s) and press tab key again to complete the name.
  • If no names match what we typed so far, then an alert sound plays as feedback.

Example

C:\Users\User>jshell
| Welcome to JShell -- Version 9.0.4
| For an introduction type: /help intro

jshell> String studentName(String firstName, String lastName)
...> {
...>    return firstName + lastName;
...> }
| created method studentName(String, String)

jshell> /methods
| String studentName(String, String)

jshell> str <Press Tab Key>
studentName(

jshell> studentName(
studentName(

Signatures:
String studentName(String firstName, String lastName)

<press tab again to see documentation>

jshell> studentName(
String studentName(String firstName, String lastName)
<no documentation found>

<press tab again to see all possible completions; total possible completions: 545>

Updated on: 21-Feb-2020

184 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements