Simple User Name
/* This is a simple program ask the user to input a name then It outputs the users name * */ import java.util.Scanner;//needed for the scanner class class B{ public static void main(String[] arg) { Scanner key = new Scanner(System.in);//Scanner class String x; System.out.print("What is your name: "); x = key.nextLine();//Stores the name into string x System.out.print("My name is " + x);//out puts the name } }
Here is the output of the program
What is your name: jj My name is jj ----jGRASP wedge2: exit code for process is 0. ----jGRASP: operation comp
< Java > <Home><Java Programs>