Also, you'll need to put data into your Name object before you can call methods to extract information out of it.
Is it in the Name class, or TestNames class? And what exactly do you mean by data?
import java.util.Scanner;
public class TestNames
{
public static void main(String [] args)
{
System.out.println("Name of first person...");
Name name = new Name();
Scanner input = new Scanner(System.in);
System.out.println("Enter your first name: ");
String firstName = input.next();
System.out.println("Enter your middle name: ");
String middleName = input.next();
System.out.println("Enter your last name: ");
String lastName = input.next();
System.out.println("Name of second person...");
Name otherName = new Name();
Scanner input2 = new Scanner(System.in);
System.out.println("Enter your first name: ");
String first = input2.next();
System.out.println("Enter your middle name: ");
String middle = input2.next();
System.out.println("Enter your last name: ");
String last = input2.next();
System.out.println("Information about the first person:");
System.out.println("Full name: " + firstName + " " + middleName + " " + lastName);
System.out.println("Last name: " + lastName + "," + firstName + " " + middleName);
//System.out.println("Initials: " + initials());
//System.out.println("Name length: " + length());
System.out.println("Information about the second person:");
System.out.println("Full name: " + first + " " + middle + " " + last);
System.out.println("Last name: " + last + "," + first + " " + middle);
//System.out.println("Initials: " + initials());
//System.out.println("Name length: " + length());
if (name != otherName)
System.out.println("The names are not the same.");
else
System.out.println("The names are the same.");
}
}
Here is what I did.. And now I can get good output for names, but the next thing is initials and length.. It is showing me the same as before that it cannot find neither method initials() nor length()..
EDIT: Also I tried to put Name name = new name(firstMiddleLast) and it is saying that it cannot find firstMiddleLast method