Go Back   Velocity Reviews > General Computer Discussion > General Help Related Topics
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

General Help Related Topics - please help: simple java coding error 'cannot be referenced from a static context'

 
Thread Tools Search this Thread
Old 10-17-2009, 06:49 AM   #1
Default please help: simple java coding error 'cannot be referenced from a static context'


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
clm90 is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46