title: In this java code how can i print out correctly the names array in the overview?
body: <p>My only question is in the overview part how can I print out the trailers rental name correctly? like this:</p>
  
  <p><a href="https://i.stack.imgur.com/KOnfQ.png" rel="nofollow noreferrer">sample</a></p>
  
  <p>But my overview code not exactly working as I want. What is the problem?
  (I understand the counting in an array starting from zero)</p>
  
  <pre><code>import java.util.Scanner;      
  
  public class TrailerRental {
  
      Scanner kb=new Scanner(System.in);
      int weightSmall=750;
      int weightLarge=3000;
      int smallTrailerCounter =0;
      int largeTrailerCounter =0;
      String smallClientName;
      String largeClientName;
      String [] smallTrailersClients=new String[5];
      String [] largeTrailersClients= new String[3];
  
      public static void main(String[] args) {
          new TrailerRental().run();
      }
  
      public void run(){
          menu();
          int menu=kb.nextInt();
  
          while (menu==1 || menu==2|| menu==3){
              if(menu==1){
                  smallTrailer();
              }
              if (menu==2){
                  largeTrailer();
              }
              if (menu==3){
                  overView();
              }
          }
          if (menu==9){
              System.out.println("Goodbye!");
          }
          else {
              System.out.println("Error, incorrect input try again!");
              System.out.println();
              run();
          }
      }
  
      public void overView() {
          System.out.println("Overview");
          System.out.println();
          System.out.println("Rented Small trailers");
          int notUsedSmallTrailer=5-smallTrailerCounter;
          for (int i=0;i&lt;smallTrailerCounter;i++){
              System.out.println("Small trailer " +(i+1) + " :" +smallTrailersClients[i] );
          }
          System.out.println("There are "+notUsedSmallTrailer+ "  out of 5 small trailers still available.");
          System.out.println("Rented Large trailers");
          int notUsedLargeTrailer=3-largeTrailerCounter;
          for(int i=0;i&lt;smallTrailerCounter;i++){
              System.out.println("Large trailer " + (i+1) +" : "+largeTrailersClients[i]  );
          }
          System.out.println("There are "+notUsedLargeTrailer+ " out of 3 large trailer still available ");
          run();
      }
  
      public void largeTrailer() {
          if (largeTrailerCounter&gt;=3){
              System.out.println("Unfortunately all Small trailers are out");
              System.out.println("Would you like to rent a Small trailer instead?(y/n)");
              String answer=kb.next();
              if (answer.equals("y")){
                  smallTrailer();
              }
              if (answer.equals("n")){
                  run();
              }
              else {
                  System.out.println("Incorrect input, return to main menu");
                  run();
              }
  
          } else {
              System.out.println("What is your name?");
              largeClientName=kb.next();
              System.out.println("Is the driver in possession of an E-type drivers license (y/n)?");
              String answer=kb.next();
              if (answer.equals("n")){
                  System.out.println("Unfortunately, a large trailer cannot be rented without a E-type drivers license. ");
                  run();
              }
              if (answer.equals("y")){
                  System.out.println("What is the weight of the load (in kg)?");
                  int weight=kb.nextInt();
                  if (weight&lt;=weightLarge){
                      largeTrailerCounter++;
                      largeTrailersClients[largeTrailerCounter]=largeClientName;
                      run();
                  }
                  if (weight&gt;weightLarge){
                      int difference=weight-weightLarge;
                      System.out.println("Warning! the maximum load "+weightLarge+" kg is exceeded by " +difference+ "kg" );
                      System.out.println("Are you sure you want to rent a trailer?(y/n)?");
                      String answer2=kb.next();
                      if (answer2.equals("n")){
                          run();
                      }
                      if (answer2.equals("y")){
                          largeTrailerCounter++;
                          largeTrailersClients[largeTrailerCounter]=largeClientName;
                          run();
  
                      }
                      else {
                          System.out.println("incorrect input,return to menu");
                          run();
                      }
                  }
              }
  
          }
  
      }
  
      public void smallTrailer() {
          if (smallTrailerCounter&gt;=5) {
              System.out.println("Unfortunately all Small trailers are out");
              run();
  
          } else {
              System.out.println("What is the customer last name?");
              smallClientName = kb.next();
              System.out.println("What is the weight of the load (in kg) ?");
              int weight = kb.nextInt();
              if (weight&lt;=weightSmall){
                  smallTrailerCounter++;
                  smallTrailersClients[smallTrailerCounter]=smallClientName;
                  run();
  
              }
              if (weight &gt; weightSmall) {
                  int difference = weight - weightSmall;
                  System.out.println("Warning the maximum load " + weightSmall + " kg is exceeded by " + difference + " kg!");
                  System.out.print("Are you sure you want to rent the small trailer? (y/n)");
                  String answer = kb.next();
                  if (answer.equals("n")) {
                      run();
                  }
                  if (answer.equals("y")) {
                      smallTrailerCounter++;
                      smallTrailersClients[smallTrailerCounter]=smallClientName;
                      run();
  
                  }
                  while (answer != "y" || answer != "n") {
                      System.out.print("Are you sure you want to rent the small trailer? (y/n)");
                      answer = kb.next();
                      if (answer.equals("n")) {
                          run();
                      }
                      if (answer.equals("y")) {
                          run();
  
                      }
                  }
              }
          }
      }
  
      public void menu() {
          System.out.println("***********************");
          System.out.println("* Trailer rental       ");
          System.out.println("***********************");
          System.out.println("* 1) Rent small trailer");
          System.out.println("* 2) Rent large trailer");
          System.out.println("* 3) Overview          ");
          System.out.println("* 9) Exit              ");
          System.out.println("***********************");
          System.out.print("Select an option:");
      }
  }
  </code></pre>