java - storing dates from a text file into an array -
in java programme have text file of dates , im trying store each array. day, month , year maintain getting stored different part of array , not please help me. these few of lines text file
12/12/1996,23/08/2000,27/02/1980
12/04/1976, 24/09/2003, 13/06/1993
30/07/1995, 20/06/2004, 23/05/1990
private static string person1date[]; private static string person2date[]; private static string person3date[]; static int count =0; person1date = new string[100]; person2date = new string[100]; person3date = new string[100]; file datefiles = new file(dates.txt); scanner dates = new scanner(datefiles); while(dates.hasnextline) { string datesline = dates.nextline(); string [] datesdetails = datesline.split(","); person1date[count] = datesdetails[0].trim(); person2date[count] = datesdetails[1].trim(); person3date[count] = datesdetails[2].trim(); count++; }
you have not initialized variable count used set position of array want store dates. write :
int count = 0;
before loop , you're done.
java
No comments:
Post a Comment