473,657 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Program - getting error cannot find symbol

30 New Member
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(St ring 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.prin tln (names.getFirst Name());
System.out.prin tln (names);
System.out.prin tln (names1.getFirs tName());

}



}
Feb 24 '07 #1
2 1786
horace1
1,510 Recognized Expert Top Contributor
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 MVP
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(St ring 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.prin tln (names.getFirst Name());
System.out.prin tln (names);
System.out.prin tln (names1.getFirs tName());

}



}
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
6963
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 classes in the directory called temp and I do cd temp to this directory. Then I do javac HelloWorld.java Now I get the compile error HelloWorld.java:9 cannot find symbol
11
13289
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 The command i am using to register the dll is
15
28812
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 System.out.println(i + ": " + sqrt(4));
1
2182
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 according to our environment. DB2 8.2 on HP-UX. Using gcc compiler. Errors are as below:
2
3004
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 class named fraction declared in a file named fraction.h, with two private data members: an int numerator and an int denominator. 2. Convert the four arithmetic functions named add, sub, mult, and div into public member functions, each accepting a...
4
5103
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 light for this error on how to rectify it. C:\Documents and Settings\wei cheng\Desktop\aa1\test.java:122: cannot find symbol symbol : method objCompare(java.lang.Object,Person) location: class test if...
11
7691
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 workplace, office supplies, music CDs, DVD movies, or software). • Create a product class that holds the item number, the name of the product, the number of units in stock, and the price of each unit. • Create a Java application that displays the...
2
6650
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) Location: class Week5MortgageGUI Week5MortgageLogic allint = logic.allInterest(amount, term, rate); Week5MortgageGUI.java:152:cannot find symbol symbol: method allInterest(double,double,double) Location: class Week5MortgageGUI
10
13071
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 source files to C:\Users\Tommy\Desktop\build\classes C:\Users\Tommy\Desktop\PlasmaMS PET\SeanSource V.5.7\src\net\sf\odinms\provider\xmlwz\FileStoredPngMapleCanvas.java:14: warning: com.sun.imageio.plugins.png.PNGImageReaderSpi is Sun proprietary API...
0
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8516
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.