System.out.print("Enter the key: ");
int n=sc.nextInt();
if(n==1)
{
System.out.println("Enter the task:");
String k=sc.nextLine();
System.out.println(k);
}
Enter the key: is printing, after giving n=1, it just print Enter the task: and the whole program is terminated. But when I give sc.next() it working but my input has more than one word, is there any problem in sc.nextLine().