how to allow user to input results in Array using java? I want to allow the user to enter a number of race results (A minimum of 2 participants and a maximum of 7) I feel that I could use a much shorter code, (I am a beginner of Java only 2 months so any recommendation would be highly useful! thank you
Code below:

int entrants = 0;
String[][] runners = new String[2][2];
boolean valid = false; //this is for the initial number of runners question - it will stay false and keep us in the loop until a number between 2-7 is entered
System.out.println("Please enter the number of runners for this race (2 to 7 entrants permitted)");
entrants = input.nextInt();
input.nextLine();

while(valid == false){

    if(entrants &lt; 2) {
        System.out.println("You need at least 2 runners for a race, please re-enter the number of runners");
        entrants = input.nextInt();
        input.nextLine();
    } else if (entrants &gt; 7) {
        System.out.println("You have entered too many runners for this race (max runners is 7). Please re-enter the number of runners");
        entrants = input.nextInt();
        input.nextLine();
    } else {
        System.out.printf("You have entered %d runners\n", entrants);
        runners = new String[entrants][2];
        valid = true;
    }
}
You have a lot of lines that do the same thing and which with a little rearranging can be consolidated:

int entrants = 0;
String[][] runners = null; //no need to create an array that you'll be throwing away
boolean valid = false; //this is for the initial number of runners question - it will stay false and keep us in the loop until a number between 2-7 is entered
System.out.println("Please enter the number of runners for this race (2 to 7 entrants permitted)");

do {
  //read the input
  entrants = input.nextInt();
  input.nextLine();

  //validate (we'll keep your messages)
  if(entrants &lt; 2) {
    System.out.println("You need at least 2 runners for a race, please re-enter the number of runners");      
  } else if (entrants &gt; 7) {
    System.out.println("You have entered too many runners for this race (max runners is 7). Please re-enter the number of runners");    
  } else {
    System.out.printf("You have entered %d runners\n", entrants);

    //create the array and set the exit condition
    runners = new String[entrants][2];
    valid = true;
  }
} while (!valid);


Note the use of a do-while which is like a while-loop but evaluates the condition after an iteration, i.e. the loop body is run at least once.

Further improvements could include putting the constraints into constants (i.e. min = 2 and max = 7) instead of having them in all over your code.