r/javahelp • u/[deleted] • Dec 12 '19
Adding values to 2D array
Hi all, I have a 2D array with 20 preset values, but as part of the project we need to add up to 100 values Here is my code as follows
Public static void PrintDiggerDetails() { String [][] DiggerList = new String[99][7]; System.out.println("==Digger Data Table=="); (Next part covers headings for printing array) System.out.print(DiggerList[0][0]"Manufacturer"); System.out.print(DiggerList[0][1]"\t\tYear"); System.out.print(DiggerList[0][2]"\tPrice"); System.out.print(DiggerList[0][3]"\tArmLength"); System.out.print(DiggerList[0][4]"\tTrack Type"); System.out.print(DiggerList[0][5]"\tStatus"); System.out.print(DiggerList[0][6]"\tWeight); } (Below this all the preset values are stored down to [19][6]) I then have a method: static void AddNewDigger() { Scanner disc = new Scanner(system.in) String strPrDOpt; strPrDOpt = disc.nextLine(); System.out.println("Manufacturer: ");
System.out.println("Year: ");
System.out.println("Price: ");
System.out.println("Arm length : ");
System.out.println("Track type: ");
System.out.println("Status: ");
System.out.println("Weight: ");
How do i add to the 2D array using these values please
}
2
u/Lizard Extreme Brewer Dec 12 '19