So I made a name class, and am using an array to store first and last names with the split function delimiting " ". Edit: Sorry its part of bigger project, it would be pointless to copy all of the code. I Have a Person Class thats composed of Name class. The person class utilizes the getStatement below, with println to print it out.
public Name(String name){
String [] nameArr = name.split(" ");
for (int i = 0; i < nameArr.length; i++){
if (i == 0)
firstName = nameArr[i];
else{
if(nameArr[i] != null){
lastName += nameArr[i];
}
}
}
}
public String getName(){
return (name.getLast() + " " + name.getFirst());
}
The out put for a give name, Joe Shmoe, Comes out to nullShome Joe... I cant figure out why =[