How to input two strings simultaneously in Java?
import java.util.Scanner; class Customer { public static void main(String[] args) { Scanner sc =new Scanner(System.in); System.out.print("Enter your name:"); String name = sc.nextLine(); System.out.print("Enter age:"); int age = sc.nextInt(); System.out.print("Enter gender:"); String gender = sc.nextLine(); System.out.print("Hailing from:"); String city = sc.nextLine(); System.out.println("Welcome, "+name+"!"); System.out.println("Age:"+age); System.out.println("Gender:"+gender); System.out.println("City:"+city); } } In the above code, only one string city(out of gender and city) is taking the input. Why not the gender? Console takes input name, age and skips for gender. Is there any other way to take two lines of strings one after the other?