Why and how do you use JShell?

I went through a couple of tutorials for JShell, and I still don't understand the most important part: why should I even use JShell?

Here is what Oracle says:

"You can test individual applications, test different method options and experiment with unfamiliar APIs in a JShell session."

Yes, great, but for all these things, I can just use the IDE. I understand that REPL should do code evaluation faster. However, testing a piece of code in the IDE in a dummy Hello World project with Sysout is probably not slower?

In fact, IDEs provide autocompletion, detect errors earlier, and I can check the implementation of the method / class with a mouse click. Should all this make code testing faster in the IDE than in JShell?

What am I missing? Can someone give me some use cases where using JShell is better than using an IDE? How do you guys use JShell?

+4
source share
1 answer

Although I really urge you to go further and read the motivation and goals of the Java Shell .

However, in order to answer your question from a small practical point of view, I would really be glad to know about the time that you will take and the procedure that you will follow when trying to try it on the IDE. So, with a few, here you go: -

1. I recently learned that Java 9 introduced Factory overloaded convenience methods for collections, and then I wondered what they do and how to use them.

Steps

-> Type 'jshell' on command prompt (assuming JAVA_HOME is set to JDK9 bin)
-> Type 'List.o'
-> Press Tab (completes the `of`) 
-> Tab displays all signatures 
-> Tab starts reading the documentation from first

enter image description here

2.. ? , List , , ..

3.. , , ? , , Map String ( ) String ( ), , . , , , . , , Java 9 , API, Java9.

enter image description here

(^^) IDE, , , Static Factory .

PS:

+4

Source: https://habr.com/ru/post/1688314/


All Articles