This is a simple Java program that reads input from the user and echoes it back.
- The program uses a
Scannerto read user input. - It then prints that input back with the prefix "Echo:".
You can run this code using any Java compiler. Here's a quick way using an online compiler:
- Visit: [https://www.programiz.com/java-programming/online-compiler/]
- Paste the code from
src/Main.java - (Optional) Click the stdin tab and enter some input like: Hello world
- Click Run
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter text: ");
String input = scanner.nextLine();
System.out.println("Echo: " + input);
}
}