please help: simple java coding error 'cannot be referenced from a static context'

Discussion in 'General Computer Support' started by clm90, Oct 17, 2009.

  1. clm90

    clm90

    Joined:
    Oct 17, 2009
    Messages:
    1
    Likes Received:
    0
    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, Oct 17, 2009
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.