A
Andy K
I am tryign to read values from an array but at the moment I am only
able to read one element a. if I set i=0 it will read onle that
element. However if I set it to 6 or any other number it wont read. I
want to be able to read this array in reverse order. What is wrong with
my for loop or the whole code.
// create array of object type Premiership with 20 elements
Premiership a[] = new Premiership[20];
int i = 0;
StringTokenizer tokens;
// this is needed to be able to split a string object into separate
components
tokens = new StringTokenizer(textLine); // to split the read string
into tokens
teamName = tokens.nextToken();
// the team name component extracted from the string
points = Integer.parseInt(tokens.nextToken());
// the points component extracted from the string
a = new Premiership(teamName,points);
for (i=0; i<=19; i++)
{
System.out.println(a.getTeamName() + " " + a.getPoints());
System.out.println(a[8]);
}
textLine = fileInput.readLine(); // Unicode format string
moreToRead = (textLine != null);
} // end of while (moreToRead)
able to read one element a. if I set i=0 it will read onle that
element. However if I set it to 6 or any other number it wont read. I
want to be able to read this array in reverse order. What is wrong with
my for loop or the whole code.
// create array of object type Premiership with 20 elements
Premiership a[] = new Premiership[20];
int i = 0;
StringTokenizer tokens;
// this is needed to be able to split a string object into separate
components
tokens = new StringTokenizer(textLine); // to split the read string
into tokens
teamName = tokens.nextToken();
// the team name component extracted from the string
points = Integer.parseInt(tokens.nextToken());
// the points component extracted from the string
a = new Premiership(teamName,points);
for (i=0; i<=19; i++)
{
System.out.println(a.getTeamName() + " " + a.getPoints());
System.out.println(a[8]);
}
textLine = fileInput.readLine(); // Unicode format string
moreToRead = (textLine != null);
} // end of while (moreToRead)