Hi.
So here's my code
public class TextFileIO
{
static Console c; // The output console
static int total;
public void askData ()
{
int line = 0;
int i;
c.print ("Enter the number of words you're going to input: ");
total = c.readInt ();
File dataInput = new File ("dataIn.text");
String[] word = new String [total];
do
{
try
{
FileWriter data = new FileWriter (dataInput);
BufferedWriter dataBuff = new BufferedWriter (data);
c.print ("Enter word" + (line + 1) + (": "));
word [line] = c.readString ();
line++;
}
catch (IOException e)
{
new Message ("Error");
}
}
while (line >total);
for (i = total; i >0; i--)
{
c.print (word[i]);
}
}
My problem is that this code shows an error? java.lang.ArrayIndexOutOfBoundsException?
for (i = total; i >0; i--)
{
c.print (word[i]);
}