+ 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 😶
4 ответов
+ 3
Thank you John 😊
+ 2
nextLine is reading what is left on the first line. Put a second in to get the second
+ 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 😶
0
This is what I meant:
https://code.sololearn.com/czf5qxMkuc5a/?ref=app