So I have text like this:
16783 BOB ARUM 30.5 10.00
A lot of these on different lines in a text file as a (long,string,string,double,double) I want to store these variables inside of an array and so far I have:
public class Main {
public static void main(String[] args){
ArrayList<String> ArrEmployee = new ArrayList<String>(); // create array for employees
try {
Scanner txtIn = new Scanner(new File("payroll.txt"));
}
catch (FileNotFoundException e) {
}
}}
The problem I'm having though is I can't figure out a way to effectively store these values inside of my arrEmployeearray in a way which I could use them later. I've figured out so far that creating a different class with a constructor could help, but I'm having a hard time understanding how to access objects in an array.
For example, if I only wanted the double at the end of the line, say it's an object stored inside an array now, how would I access that specific double?
Stringor store them within aListofObject, but that's a lot of extra work when it comes to converting them back and forwards. It would simpler to create a POJO, load the values into it and store that within yourList