Hi all, I'm just getting started with Java and created a simple app. Please see the code and the output. Where did I go wrong? Do I need to set the variable of "display" on top of the input? Why is the input not being stored as a variable?
import java.util.Scanner; public class UserInput { public static void main (String args[]){ Scanner jason = new Scanner(System.in); String fname; String lname; String addr1; String addr2; String display; System.out.println("Enter first name: "); fname = jason.nextLine(); System.out.println("Enter last name: "); lname = jason.nextLine(); System.out.println("Enter Address 1: "); addr1 = jason.nextLine(); System.out.println("Enter Address 2: "); addr2 = jason.nextLine(); display = ("fname, lname, addr1, addr2"); System.out.println("The information you entered is: "+ display); } }
Enter first name:
Joe
Enter last name:
Rogan
Enter Address 1:
123 Fastlane
Enter Address 2:
LA CA 90211
The information you entered is: fname, lname, addr1, addr2