

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the different "/types" commands in JShell in Java 9?
<p style=""><strong>JShell </strong>tool has introduced in <strong>Java 9 </strong>version. It is also called a <strong>REPL</strong>(Read-Evaluate-Print-Loop) tool that allows us to execute Java code and getting immediate results. We need to list out the declared types like <strong>class</strong>, <strong>interface</strong>, <strong>enum</strong>, and etc by using the "<strong>/types</strong>" command.</p><p style="">Below are the different "<strong>/types</strong>" commands in JShell.</p><pre class="prettyprint notranslate"><strong>/types /types [ID] /types [Type_Name] /types -start /types -all</strong></pre><ul class="list"><li><strong>/types:</strong> This command lists all active types (class, interface, enum) created in JShell.</li><li><strong>/types [ID]:</strong> This command displays the type corresponding to the id <strong>[ID]</strong>.</li><li><strong>/types [Type_Name]:</strong> This command displays the type corresponding to <strong>[Type_Name]</strong>.</li><li><strong>/types -start:</strong> This command allows us to list the types that have been added to the JShell startup script</li><li><strong>/types -all:</strong> This command allows us to list all types of the current session (active, inactive and loaded when JShell starts).</li></ul><p style="">In the below code snippet, created class, interface, and enum types. Then, we can apply different "<strong>/types</strong>" commands. </p><pre class="prettyprint notranslate" style=""><strong>jshell> enum Operation { ...> ADDITION, ...> DIVISION; ...> } | created enum Operation jshell> class Employee { ...> String empName; ...> int age; ...> public void empData() { ...> System.out.println("Employee Name is: " + empName); ...> System.out.println("Employee Age is: " + age); ...> } ...> } | created class Employee jshell> interface TestInterface { ...> public void sum(); ...> } | created interface TestInterface jshell> /types | enum Operation | class Employee | interface TestInterface jshell> /types 1 | enum Operation jshell> /types -start jshell> /drop Operation | dropped enum Operation jshell> /types -all | enum Operation | class Employee | interface TestInterface</strong></pre>
- Related Questions & Answers
- What are the different "/vars" commands in JShell in Java 9?
- What are the different "/edit" commands in JShell in Java 9?
- What are the useful commands in JShell in Java 9?
- How to display different list commands in JShell in Java 9?
- What are the different shortcut keys in JShell in Java 9?
- What are the different feedback modes in JShell in Java 9?
- What are the different startup scripts in JShell in Java 9?
- What are the different module types in Java 9?
- JShell in Java 9?
- What are the different commands used in MySQL?
- How to declare reference types in JShell in Java 9?
- What are the rules for external declarations in JShell in Java 9?
- What are the rules we need to follow in JShell in Java 9?
- What are the different types of keywords in Java?
- What are the different types of classes in Java?
Advertisements