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());
}
}
2 1786 horace1 1,510
Recognized Expert Top Contributor
this requires a constructor with no parameters -
Name names1 = new Name ();
-
e.g. -
public Name( )
-
{
-
firstName = "no";
-
lastName = "name";
-
}
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 - public Name( String first ,String last)
-
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
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
|
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));
|
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:
|
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...
| |
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...
|
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...
|
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
|
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...
|
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,...
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
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();...
|
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...
| |
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
| |