How to input user text and output it in a console
239 viewsHere is a sample code I wrote to input and output text in a console. This is useful if you want input in your application.
public class ScannerDemo {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print(”Input: “);
String text = sc.nextLine();
System.out.println(”output: ” + text);
sc.close();
}
}
Output:
Input: This is some input text that i typed
output: This is some input text that i typed












