简体   繁体   English

如何在同一行中获得不同的输入?

[英]How to get different inputs in the same line?

I want to get different inputs in the same line in java, but instead of just printing them all at once i want to store then as a string or integer etc... I can´t find a solution, thanks.我想在 java 的同一行中获得不同的输入,但是我不想一次打印它们,而是想将它们存储为字符串或 integer etZ4A8A08F09D37B73795349038't 找到解决方案,谢谢...

You can import them by a deliminator then call the split function on the string and store the results in an array.您可以通过分隔符导入它们,然后在字符串上调用拆分 function 并将结果存储在数组中。

String input = scan.nextLine();
//Your input is: FirstName, LastName, DOB
String[] inputArr = input.split[","];
// inputArr[0] -> "firstName" etc..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM