import java.util.Scanner;
public class Name
{
String lastName;
String firstName;
Scanner scan = new Scanner(System.in);
public Name(String LastName, String FirstName)
{
lastName = LastName;
firstName =FirstName;
};
public String getFirstName()
{
return firstName;
}
public void setFirstName (String FirstName)
{
firstName = FirstName;
}
public String getLastName()
{
return lastName;
}
public void setLastName (String LastName)
{
lastName = LastName;
}
public String toString()
{
String name = ("name: " + this.getLastName()+ ", " +this.getFirstName());
return name;
}
}
ChevaneHeadChefCooke
0
Newbie Poster
Recommended Answers
Jump to PostI don't get any compiler error when trying to compile the piece of code that you've posted.
Please post the piece of code that results in the compiler error you've described.
Jump to Postmy doubt is that right after his constructor, he has a ; which shouldn't be there.
when debugging, don't look for the obvious, look for that what is either missing, or shouldn't be there at all.
All 6 Replies
ChevaneHeadChefCooke
0
Newbie Poster
mvmalderen
2,072
Postaholic
stultuske
1,116
Posting Maven
Featured Poster
IIM
163
Master Poster
stultuske
1,116
Posting Maven
Featured Poster
mvmalderen
2,072
Postaholic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.