简体   繁体   English

你如何让你的程序打印出用户输入的值的数量?

[英]How do you get your program to print out the number of values a user has entered?

For example, if a person entered the numbers 22,44,55,33,77,443.例如,如果一个人输入了数字 22、44、55、33、77、443。 It would print out "6 numbers have been entered".它会打印出“已输入 6 个数字”。

Perhaps you're looking for String.split , for example:也许您正在寻找String.split ,例如:

String input = "22,44,55,33,77,443";
System.out.printf("%d numbers have been entered\n", input.split(",").length);

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

相关问题 如何获得该程序以打印出用户输入的数字? - How can I get this program to print out the numbers the user entered? 您如何检查用户输入的是字符串值而不是数字? - How do you check that the user entered a String value instead of a number? 如果您询问用户(“输入数字(1-99)或按 0 退出”),并且用户输入了 0,如何终止 Java 程序? - How to terminate a program Java if you asked the user ("Enter a number (1-99) or press 0 to EXIT"), and the user entered 0? 编译程序后,如何从源文件夹中获取 jar? - How do you get a jar from your source folder after you compile your program? 输入用户打印输出数组 - Print out array user entered 您如何调用在UI中输入的值给Java类? - how do you call a value entered in a UI to your java class? 我如何使程序保持循环,直到用户输入了整数 - How do i make the program keep looping until the user has entered an integer 如何仅获取用户在 numGames() 中输入的值并避免程序打印“你叫什么名字?” 再次? - How can I get only the value entered by the user in numGames() and avoid the program from printing “What's your name?” again? 如何获得用户输入的数字以退出循环? - How to get a number entered by the user to exit a loop? Java:如何在用户输入数字之前打印相应的字母? - Java: How to print corresponding alphabets till a number entered by user?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM