473,385 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Program - getting error cannot find symbol

i cant understand why it says cannot find symbol can you guys look thanx
i can get it to show john doe but not my next name.

class Name
{

public String firstName ="carl";
private String lastName = "Johnson";

public Name( String first ,String last)
{
firstName = first;
lastName = last;
}

void setFirstName(String first)
{
firstName = first;
}
public String getFirstName()
{
return firstName;
}

public String getLastName()
{
return lastName;
}

public String toString()
{
return "Name" + lastName + "," + firstName;
}


}

public class NameDriver
{
public static void main(String args[])
{
Name names = new Name("John", "Doe");
Name names1 = new Name ();
System.out.println (names.getFirstName());
System.out.println (names);
System.out.println (names1.getFirstName());

}



}
Feb 24 '07 #1
2 1779
horace1
1,510 Expert 1GB
this requires a constructor with no parameters
Expand|Select|Wrap|Line Numbers
  1.      Name names1 = new Name ();
  2.  
e.g.
Expand|Select|Wrap|Line Numbers
  1. public Name( )
  2. {
  3. firstName = "no";
  4. lastName = "name";
  5. }
Feb 24 '07 #2
r035198x
13,262 8TB
i cant understand why it says cannot find symbol can you guys look thanx
i can get it to show john doe but not my next name.

class Name
{

public String firstName ="carl";
private String lastName = "Johnson";

public Name( String first ,String last)
{
firstName = first;
lastName = last;
}

void setFirstName(String first)
{
firstName = first;
}
public String getFirstName()
{
return firstName;
}

public String getLastName()
{
return lastName;
}

public String toString()
{
return "Name" + lastName + "," + firstName;
}


}

public class NameDriver
{
public static void main(String args[])
{
Name names = new Name("John", "Doe");
Name names1 = new Name ();
System.out.println (names.getFirstName());
System.out.println (names);
System.out.println (names1.getFirstName());

}



}
You have a constructor
Expand|Select|Wrap|Line Numbers
  1.  public Name( String first ,String last)
  2.  
so the default no-args constructor is not automatically created for you by the compiler therefore you can't call the no-arg constructor as it is not there. Have a read at this.
Feb 26 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Tony Johansson | last post by:
Hello! I get compile error when compiling using the command javac from the command terminal window(CMD). I have just two classes which are called HelloWorld.java and Slask.java. I have both...
11
by: Vijay Chegu | last post by:
I have built a 64bit ATL COM dll. When i register the dll on IA64 windows Enterprise server 2003, i get following error. DllRegisterServer in mydll.dll failed. Return code was : 0x80020009 ...
15
by: Bjorn Jensen | last post by:
Hi! An beginner question: Pleas help me with this (-: Error (the arrow points on the s in sqrt) ===== tal.java:6: cannot find symbol symbol : method sqrt(int) location: class tal...
1
by: Divakar | last post by:
Hi, We are getting the following error while compiling the UserExit program. Not sure where the problem is. We are using the IBM supplied UserExit sample program. We have changed some variables...
2
by: d0ugg | last post by:
Hi, I'm doing a FRACTION program for one of my Programming classes and I'm getting some errors that I can't figure it out. Here is the Assignment: 1. Convert the fraction structure into a...
4
by: jingchua | last post by:
Hi, can anyone help out here???? I have the below error after compling the file. Any idea what is wrong in the declaration that was done in the above code??? Appreciate any help on shedding some...
11
by: hamiltongreg | last post by:
I am new to Java and am having problems getting my program to compile correctly. My assignment is as follows; Choose a product that lends itself to an inventory (for example, products at your...
2
by: karinmorena | last post by:
I'm having 4 errors, I'm very new at this and I would appreciate your input. The error I get is: Week5MortgageGUI.java:151:cannot find symbol symbol: method allInterest(double,double,double)...
10
by: CodeNoob | last post by:
please help been working on a project got it down to 5 errors from 100 now i have no idea what to do. Errors: init: deps-jar: Created dir: C:\Users\Tommy\Desktop\build\classes Compiling 306...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.