I am writing an airline program that will allow the user to input names and meal choice for each seating section economy, business, and first. I am trying to save all the names and meals into an array. but I am getting a syntax error.
I get expected message when I implement my flyer array.
I have looked on stack overflow. From what I can tell it should be ok to initialize my array this way.
Thanks for any help.
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Flyers
{
public Flyers()
{
}
public List<String> seat = new ArrayList<>();
int numberOfFlyers;
int numberOfMeals;
String name;
String meal;
String[][] flyer;
public void addEconomyFlyer()
{
Scanner in = new Scanner(System.in);
System.out.print("Enter number of economy seats sold: ");
numberOfFlyers = in.nextInt();
flyer = new [numberOfFlyers][numberOfFlyers];
}
}
new [numberOfFlyers][numberOfFlyers]does and why do you think so?flyera two-dimensional array? It doesn't make much sense to me.I have looked on stack overflow. From what I can tell it should be ok to initialize my array this wayPlease link a question/answer you saw that showed your initialization as ok.new String[numberOfFlyers][numberOfFlyers]will create 90000 Strings. Do you think you might be better off with two one-dimensional arrays? One for the names and one for the meal choices?