0
Hello I started studying java a little while ago and I came across a problem :
import java.util.Scanner;
public class MainD {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int i = scan.nextInt();
if(i == 1) {
System.out.println("string a");
String a = scan.nextLine();
System.out.println("string b");
String b = scan.nextLine();
}
}
}
Seal on executing.
1
Digite a string a
Digite a string b
When executing this code he ends up executing the four lines stopping only in the last nextLine(), next() would solve this but only add a word, someone could explain to me why, since I thank you. ps I am studying programming just 3 weeks.