はじめての記事です。気合いれましょう。シャオラ。 【現象】nextInt()のあとにnextLine()を書くとスキップされる ①例えばこのようなコードがあるとします。(Scannerクラスは”scanner”としてimportしてある状態) System.out.println("あなたの名前を入力してください。
🚨 𝐉𝐚𝐯𝐚 𝐒𝐜𝐚𝐧𝐧𝐞𝐫 𝐆𝐨𝐭𝐜𝐡𝐚! Ever noticed how nextLine() gets skipped after using nextInt()? Here's why: When you call nextInt(), Java reads the number but leaves the newline (\n) in the ...
“Insanity is doing the same thing over and over again and expecting different results.” -> Albert Einstein I kept running into a strange issue in Java where scanner.nextLine() seemed to be skipped ...
hasNextLine メソッドは、Java の Scanner クラスのメソッドの1つで、次の行が存在するかどうかを確認するために使われます。主に、ファイルや標準入力(コンソールなど)から入力を読み取る際に使用されます。 このメソッドは次の行が存在する場合に true を ...