The application should have one method that populates the multidimensional array with data and another method that shows the contents
of the multi dimensional array. Both methods should be triggered from the main method. Assist because am been notified that the code below is not correct
public class ArrayExample {
// Getting logger used for logging statements.
public Logger logger =
Logger.getLogger( ArrayExample.class );
/**
* Constructor
*/
public ArrayExample() {
super();
}
/**
* Demonstates initializing and populating a multi-dimensional array in
* several statements
* multi dimensional array that stores
* information for 5 people:
* First Name
* Last Name
* Date of Birth
*/
private String [][] personalDetails() {
logger.debug( "personalDetails()" );
String personArray[][]= {
{ "John","Kamau", "30 march 1984" },
{ "Kevin","Kubai", "30 March 1988" },
{ "Suzzie","Gichia","23 December 1992" },
{ "Wayne","Rooney","1 August 1986" },
{ "Bob","Marley", "16 February 1945" }
};
return personArray;
}
/**Shows the contents of the multidimesional Array
*
*/
private void personalDetailsContent( ) {
logger.debug( "personalDetailsContent()" );
String [][] personArray= personalDetails();
for(int i=0; i<personArray.length; i++){
for(int x=0; x<personArray[i].length; x++){
System.out.print(personArray[i][x]+"\t");
}
System.out.println();
}
}
/**
* This is the starting execution point of the program.
*
* @param args the args are parameters passed into this java program from
* the command line.
*/
public static void main( String[] args ) {
// Configure the logger to print to the screen
BasicConfigurator.configure();
ArrayExample arrayExample = new ArrayExample();
arrayExample.personalDetails();
arrayExample.personalDetailsContent( );
}
}