Well, the code you provided cannot be compiled as is. First of all, FileWriter class has no write() method, so out.write(); will prevent you from compiling the code. Also I think there is one closing brace more than it should be, but I will suppose you made a mistake when pasting the code.
There is also something that looks wrong with the logic. You are trying to write to file inside the for loop. So what the output file would contain is the amount returned only from the last element of your StaffList array increased by value of basic. However, if you wanted to save the data for each element of your StuffList array, you would have to initialize FileWriter before you enter the for loop, write the data inside the for loop, and close the output after it. Basically, it should look like this:
And what's the purpose of the code marked as Reading a file? If you need to read the file too, than you should put that in separate method. Also, naming a method holidays() for this task doesn't seem like a very good choice to me.
The quieter you are, the more you are able to hear.
posted 6 years ago
OK, I Fixed up the Loop,
but my main problem doesnt seem to want to fix itself,
Here is my String
I Used a ArrayList and got the String to Print to text file, but i cant seem to get it to work on an Array