Help! The only thing I seem to not get is the initials from the substring........... any ideas?

public class Name {

   //Data Members
   private String firstName;
   private String middleName;
   private String lastName;
    private String initials;

  //Default constructor

      Name() {

      firstName = null;
      middleName = null;
      lastName = null;

   Name(String newFirstName, String newMiddleName, String newLastName){
   firstName = newFirstName;
   middleName = newMiddleName;
   lastName = newLastName;

   //Mutator methods

   public void setFirstName(String newFirstName){
   firstName = newFirstName;
   public void setMiddleName(String newMiddleName){
   middleName = newMiddleName;
   public void setLastName(String newLastName){
   lastName = newLastName;

   //Accessor method
   public String getFirstName(){
      return firstName;
   public String getMiddleName(){
      return middleName;
   public String getLastName(){
      return lastName;

   //Returns the total number of characters in the full nmae, not including spaces

   public void concat(){
        String fullName=firstName.concat(middleName).concat(lastName);
        int lengthName=fullName.length();
        System.out.println("The length in characters of " + firstName + " " +middleName+ " " + lastName + " is: " + lengthName);

   //Returns firstname middle last name initial with 3 character initials for example CMP
   public void substring(){
        initials = firstName.substring(0) + middleName.substring(0) + lastName.substring(0);

   //Returns a string containing the person's full name with last name first followed by a comma
      public void lastNameFirst(){
        String s = lastName.concat(", ").concat(firstName).concat(" "+middleName.substring(0));
    public void fullNameInitials(){
        String f = firstName.concat(" " +middleName).concat(" "+lastName+" ") + initials;

public class NewNamesList {
   public static void main(String[] args){

   Name[] namesList = new Name[2];

   namesList[0] = new Name("Jessica", "Mary", "Preston");
   namesList[1] = new Name("Cheyenne", "Mary", "Palmore");



Edited 3 Years Ago by mike_2000_17: Fixed formatting

It seems like you have three Strings, firstName, middleName, and lastName. If that is the case, use

String initials = firstName.charAt(0) + middleName.charAt(0) + lastName.charAt(0);

instead of the substring method you're using.

Edited 7 Years Ago by BestJewSinceJC: n/a

//Returns firstname middle last name initial with 3 character initials for example CMP
  	public char charAt(int index){
   String initials = firstName.charAt(0) + middleName.charAt(0) + lastName.charAt(0);    

i'm getting an error of incompatible types for Line 3

This question has already been answered. Start a new discussion instead.