Please help me in the below code :
import java.util.Scanner;
class A
{
public static void main(String args[])
{
Scanner Sc = new Scanner(System.in);
System.out.print("Enter first number : ");
a = Sc.nextInt();
System.out.print("Enter second number : ");
b = Sc.nextInt();
System.out.print("Sum is : " + (a + b));
System.out.print("Press enter to continue...");
/* HERE IS MY DOUBT */
/* WHAT TO WRITE HERE SO THAT WHEN "ENTER" IS PRESSED THEN CODE PROCEEDS */
}
}
Like in C language we can use getch() to hold a program. Is there something similar in Java too?
I have already tried Sc.nextLine(). The problem with Sc.nextLine() is that, in it first I have to enter a value and then press enter and then the code proceeds. But what I want is to just press enter and proceed.