+ 2

Can someone find why my code doesn't work please?

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner AA = new Scanner(System.in); double AAA = AA.nextDouble(); String BBB = AA.nextLine(); System.out.println(BBB); } } It's supposed to print out the second line in the user input but nothing happens.Help please šŸ˜¶

14th Dec 2017, 8:55 PM
Clarke
Clarke  - avatar
4 Answers
+ 3
Thank you John šŸ˜Š
15th Dec 2017, 3:30 PM
Clarke
Clarke  - avatar
+ 2
nextLine is reading what is left on the first line. Put a second in to get the second
14th Dec 2017, 9:01 PM
John Wells
John Wells - avatar
+ 2
What do you mean - I don't understand ā˜¹ļø I put two lines in like this in the user input: 1 a it was supposed to print out the a but it did nothing Then I tried: import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner AA = new Scanner(System.in); double AAA = AA.nextDouble(); String BBB = AA.nextLine(); System.out.println("\n" + BBB); } } It didn't even print out the "\n" Someone tell me what's happening please šŸ˜¶
15th Dec 2017, 2:49 PM
Clarke
Clarke  - avatar
15th Dec 2017, 3:11 PM
John Wells
John Wells - avatar