Using Custom Data Types in Java
<p>I am new to programming and I have an assignment to write a class called Names.  In my main method, I want to read in the entire name and pass it to my Names constructor.  However, I keep getting type mismatch errors when passing the method data.  What am I doing wrong??</p>

<pre><code>import java.util.Scanner;
public class Names {
String first, middle, last;
    /**
     * @param args
     */
    public Names(){

    }
    public Names(String first, String middle, String last){
        first = this.first;
        middle = this.middle;
        last = this.last;
    }

    //returns the first name
    public String getFirst(){
        return first;
    }

    //returns the middle name
    public String getMiddle(){
        return middle;
    }
    //returns the last name
    public String getLast(){
        return last;
    }
    // Returns a string containing the person's full name in order,
    public String firstMiddleLast(){
        String ret = first + " " + middle + " " + last;
        return ret;
    }
    public String lastFirstMiddle(){
        String ret = last + ", " + first + " " + middle;
        return ret;
    }
    public boolean equals(Names otherName){
        if (first.equalsIgnoreCase(otherName.first) || middle.equalsIgnoreCase(otherName.middle) 
                || last.equalsIgnoreCase(otherName.last))
            return true;
        else
            return false;
    }
    public String initials(){
        String retVal = first.substring(0) + "." + middle.substring(0) + "." + last.substring(0) + ".";
        return retVal.toUpperCase();
    }
    public int length(){
        String wholeName = (first+middle+last);
        int retVal = wholeName.length();
        return retVal;
    }
    public static void main(String[] args) {
        Names person1 = new Names();
        Names person2 = new Names();
        Scanner scan = new Scanner(System.in);

        System.out.println("Enter First Name: ");
        person1.first = scan.next();

    }

}
</code></pre>
