This question already has an answer here:
import java.util.Scanner;
public class first2 {
public static void main(String[] args) {
int i;
String dl;
Scanner in = new Scanner(System.in);
System.out.println("Enter value of i");
i=in.nextInt();
if (i<5)
{
System.out.println("Enter name ");
dl=in.nextLine();
System.out.println(dl);
}
else{
System.out.println("Wrong");
}
in.close();
}
}
The program terminates after taking the value of 'i' and gives the output "Enter your name" and never asks for the value of 'dl'. HELP!!
Aucun commentaire:
Enregistrer un commentaire