我給這個輸入「歡迎來到HackerRank的Java教程!」但使用掃描儀類打印字符串
只通過掃描儀類打印「歡迎」字符串。
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int i = scan.nextInt();
double d = scan.nextDouble();
String s = scan.nextLine();
scan.close();
// Write your code here.
System.out.println("String: " + s);
System.out.println("Double: " + d);
System.out.println("Int: " + i);
}
}
如何解決這個問題?
此代碼絕不會打印「歡迎」 –
https://www.hackerrank.com/challenges/java-stdin-stdout/editorial您的問題有答案。 –
歡迎來到Stack Overflow!您能否在解決問題的努力中獲得更好的標題和更詳細的內容信息? – manetsus