java - 'Get' method is returning null when called -


i trying return name of user class have set up, when getname called, null returned. doing wrong?

public class investor {   private string firstname;   private string lastname;    public string getname(){     return firstname + " " + lastname;     }   public void setname(int userindex){     arraylist<string> firstnamelist = new arraylist<string>();     arraylist<string> lastnamelist = new arraylist<string>();     string line = "";       try{            filereader fr = new filereader("investments.txt");            bufferedreader br = new bufferedreader(fr);             while((line = br.readline()) != null) {                 line.split("\\s+");                 firstnamelist.add(line.split("\\s+")[3]);                 lastnamelist.add(line.split("\\s+")[4]);             }         }         catch(ioexception e){             system.out.println("file not found!");         }      this.firstname = firstnamelist.get(userindex);     this.lastname = lastnamelist.get(userindex); } 


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -