jshell中的多行粘贴 [英] Multiline paste in jshell

查看:105
本文介绍了jshell中的多行粘贴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用jshell,但找不到粘贴多行表达式的选项。甚至可以在jshell中粘贴多行。类似于scala提供的粘贴模式

I was trying out jshell and couldn't find option to paste multiple line expressions. Is it even possible to paste multiple lines in jshell. Similar to what scala offers with paste mode.

推荐答案

所以如果你有这样的代码:

So if you have code like this:

 int c = 2;
 int j = 4;
 int x = 5; 

复制并粘贴到jshell中,只处理前两个语句。

Copy and paste into jshell, only the first two statements are processed.

但如果你有这样的代码:

But if you have code like this:

  int c = 2; int j = 4; int x = 5;

并粘贴到jshell:

And paste into jshell:

jshell> int c = 2; int j = 4; int x = 5;
        c ==> 2
        j ==> 4
        x ==> 5 

更多这样的代码行:

HashMap<Integer, Integer> map2 = new HashMap<>(); for (int i = 0; i < 15; ++i) { map2.put(i, i);map2.put(i, i); } System.out.println(map2);

实际上会有效。

为什么?我不知道。

我知道复制/粘贴的唯一方法是通过(在jshell中输入):

The only way I know that copy/paste will work is via (type it in jshell) :


/ edit

/edit

你可以粘贴为你想要的很多。

and you can paste as much as you want.

这篇关于jshell中的多行粘贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆