File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark ""Error: cannot find symbol"" Watch ""Error: cannot find symbol"" New topic
Author

"Error: cannot find symbol"

Dan Knight
Greenhorn

Joined: Feb 17, 2006
Posts: 2
A few years ago at college, I had to develop a simple database in Java. Out of the blue, I decided to have another go (from scratch) but I've fell at the first hurdle. I use BlueJ for developing. The class compiles without any problems but when I come to create an object, I'm told "Error: cannot find symbol". I thought the code was practically idenitical to what worked at college but here goes...

Class: Customers

public class Customers
{
// instance variables - replace the example below with your own
public String customerID;
private String title;
private String firstName;
private String surname;
private String date;
private String initials;
private String department;
private String addressOne;
private String addressTwo;
private String city;
private String county;
private String postcode;
private String country;
private String telephone;
private String extension;
private String fax;
private String mobile;
private String email;
private String website;
private String history;
private String notes;

/**
* Constructor for objects of class Customers
*/
public Customers(String cTitle, String cFirstName, String cSurname, String cDate, String cInitials, String cDepartment,
String cAddressOne,String cAddressTwo, String cCity, String cCounty, String cPostcode, String cCountry, String cTelephone,
String cExtension, String cFax, String cMobile, String cEmail, String cWebsite, String cHistory, String cNotes)
{
// pass data into previous variables
title = cTitle;
firstName = cFirstName;
surname = cSurname;
date = cDate;
initials = cInitials;
department = cDepartment;
addressOne = cAddressOne;
addressTwo = cAddressTwo;
city = cCity;
county = cCounty;
postcode = cPostcode;
country = cCountry;
telephone = cTelephone;
extension = cExtension;
fax = cFax;
mobile = cMobile;
email = cEmail;
website = cWebsite;
history = cHistory;
notes = cNotes;

}
}

Thanks in advance!


Moo
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3426
    
  12
Is that the whole error message or does it tell you what symbol it can't find or which line of code it is failing on ?


Joanne
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Hi Dan,

Welcome to JavaRanch!

I cut-and-pasted this class into a file, and (despite the fact that you've got a mind-boggling number of constructor parameters and member variables, more than enough to virtually ensure a typo if it were my code!) it compiles, no problem. Does the error message specify a file and line number where the error occurs? Can you show us the code that error message points to?


[Jess in Action][AskingGoodQuestions]
Dan Knight
Greenhorn

Joined: Feb 17, 2006
Posts: 2
Hey guys,

Thanks for the responses.

It doesn't give me anymore information other than "Error: cannot find symbol". It compiles OK so I don't understand what the problem is. When trying to create a new customer object, though, I enter some nonsensical data to fill the fields and then it tells me there's an error.

Frustrating! Discouraging! Possible cause for baldness, either stress-related or due to taking aggression out on it!

* * * * * * * * * * * * * * *
Edit:
* * * * * * * * * * * * * * *

Wow. Big wow. Really big wow.

The problem was that I didn't use speech marks when trying to assign value to my variables. I don't know whether that's just a BlueJ thing but in any case, I shall never visit this site again out of sheer embarassment of immense stupidity!
[ February 17, 2006: Message edited by: Dan Knight ]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Relax, Dan. "Java in General (Beginner)", it's called. Everybody is a beginner once.

Yes, the value of a String (as opposed to the name of a variable) is written in double quotes (the preferred term.) The "cannot find symbol" message comes from the compiler thinking your unquoted String looked like a variable name -- but it couldn't find such a variable.
 
wood burning stoves
 
subject: "Error: cannot find symbol"
 
Similar Threads
Address Book Java Issues
How to add JPA ManyToMany records?
help with loop
scanner variables into object for insertion into database.
I need to get only simple tag names in response xml into Arraylist