๐งช Step 1: Import the Scanner
Before using it, you need to import it at the top of your code:
Before using it, you need to import it at the top of your code:
import java.util.Scanner;
✏️ Example: Asking for a Name
import java.util.Scanner;
public class InputExample {
public static void main(String[] args) {
Scanner input = new Scanner(System.in); // Create Scanner
System.out.print("What's your name? ");
String name = input.nextLine(); // Read a line of text
System.out.println("Hello, " + name + "!");
}
}
Tired of just printing "Hello World"? It’s time to build something real. ๐ป If you're learning Java and want to stand out, ...
No comments:
Post a Comment