R
RookThis
I'm new to Java and trying to understand the array process. I have
file that I am trying to read in and populate an array with the
data. I have this so far, but still having problems. Can someone
tell me what I'm doing wrong? Thank you!
public class test
{
public static void main (String [] args)throws Exception
{
Scanner ifile1 = new Scanner(new File("input.txt"));
String type = " ";
String color = " ";
String description = " ";
String make = " ";
int ccount = 0;
int index = 0;
carFile[] items = new carFile[50];
while (ifile1.hasNext())
{
type = ifile1.next();
color = ifile1.nextInt();
description = ifile1.next();
make = ifile1.nextLine();
items[index].setType(type);
items[index].setColor(color);
items[index].setDescription(description);
items[index].setMake(make);
index++;
}
ifile1.close();
}
}
file that I am trying to read in and populate an array with the
data. I have this so far, but still having problems. Can someone
tell me what I'm doing wrong? Thank you!
public class test
{
public static void main (String [] args)throws Exception
{
Scanner ifile1 = new Scanner(new File("input.txt"));
String type = " ";
String color = " ";
String description = " ";
String make = " ";
int ccount = 0;
int index = 0;
carFile[] items = new carFile[50];
while (ifile1.hasNext())
{
type = ifile1.next();
color = ifile1.nextInt();
description = ifile1.next();
make = ifile1.nextLine();
items[index].setType(type);
items[index].setColor(color);
items[index].setDescription(description);
items[index].setMake(make);
index++;
}
ifile1.close();
}
}