Couchbase 的 Spring Data:使用 AND ANY ... SATISFIES

所以我想制作一个命令行计算器,它在“Calculator”一词之后接受多个参数。但使用以下代码我无法实现它。在这两种方法中,gradle 都会在显示单词“Calculator”之前等待读取该行。


使用扫描仪


System.out.print("Calculator ");

Scanner sc = new Scanner(System.in);

String inputString;

inputString = sc.nextLine();

String[] args = inputString.split( "\\s+" );

使用BufferReader


BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

System.out.print("Calculator ");

String str= br.readLine();

String[] args = str.split( "\\s+" );

但是 System.out.println("Calculator ") 显示该单词没有任何问题。但它并不在一条线上。所以它不能按我想要的方式工作。更改代码行的顺序也没有帮助。


System.Console().printf() 也不是一个选项,因为我使用的是 Intellij IDEA。那么有人可以帮我解决这个问题,以便我可以获得内联输入阅读器。我还尝试通过在方法中单独实现来同步打印方法。那效果不太好。


最后我想要实现的是以下格式


计算器 最大 12 23 25 45


这里斜体是要读取的输入。

粗体部分应由程序打印。

这是完整的代码


MM们
浏览 63回答 1
1回答

倚天杖

您需要定义您的reference typein CouchbaseRepository<T, K>,然后只需添加引用类型ItemasCouchbaseRepository<BendicionesDoc<Item>, String>并仅使用存储库查询关键字for findById(String id)。public interface BenRepository extends CouchbaseRepository<BendicionesDoc<Item>, String> {      List<BendicionesDoc<Item>> findById(String id); }
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java