![]() |
|
|
|||||||
![]() |
General Help Related Topics - please help: simple java coding error 'cannot be referenced from a static context' |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Im trying to read in a string through console and store the two distinct words into two different variables. I've tried a number of ways but keep getting errors that i dont know how to solve. could someone help please?
heres the code (i deleted some parts i thought irrelevant) public class Contact extends Person { static Scanner console = new Scanner (System.in); private Address address; private Date dob; private String phoneNumber; Contact contactTest = new Contact(); /** * Constructor; */ public Contact(Scanner input, boolean prompt) { String firstName = ""; String lastName = ""; if (prompt==true) { System.out.println("Enter first and last name"); firstName = contactTest.Scanner.next(); lastName = contactTest.Scanner.next(); ________________ So far i have tried a)firstName = Scanner.next(); and b) the code just above. the error list i get is: 1. a)cannot find symbol constructor Contact(); 2. a) cannot find variable Scanner 3. B) (nonstatic method cannot be reference from s static context clm90 |
|
|
|
|