public class hello { { } }
import java.util.Scanner; //imports the scanner method, making it possible to use later on for user input public class greeting { { Scanner input = new Scanner(System.in); //this creates a scanner object which reads the user's input System.out.print("What is your name? "); //this asks the user for their name. a space is left after the question mark for neatness String name = input.nextLine(); //this takes the user's input, and assigns it to a new variable called name. string variables are made up of any collection of characters System.out.println("Hello, " + name + "!"); //this replaces "world" with the user's name. note the + signs here. they connect variables and quoted text, allowing them to be used together. } }