title: Java arrays: select and replace values via user inputs
body: <p>In the program I'm creating, the user will input values to create an array of videos. Each video contains several data fields (number, title, publisher, duration &amp; date). However what I am currently trying to acheive is to let the user choose a particular video in the array they just created, select the data field they wish to rename, rename the value and then set the renamed value as the new value. Here is my code for adding videos to an array:</p>
  
  <pre><code>public Library createLibrary()
  {
      Library video = new Library();
      java.util.Scanner scannerObject =new java.util.Scanner(System.in); 
      for (int i = 0; i &lt; videos.length; i++)
      {
      //User enters values into set methods within the Library class
      System.out.print("Enter video number: " + (i+1) + "\n");
      String number = scannerObject.nextLine();
      System.out.print("Enter video title: " + (i+1) + "\n");
      String title = scannerObject.nextLine();
      System.out.print("Enter video publisher: " + (i+1) + "\n");
      String publisher = scannerObject.nextLine();
      System.out.print("Enter video duration: " + (i+1) + "\n");
      String duration = scannerObject.nextLine();
      System.out.print("Enter video date: " + (i+1) + "\n");
      String date= scannerObject.nextLine();
      System.out.print("VIDEO " + (i+1) + " ENTRY ADDED " + "\n \n");
      //Initialize arrays
      videos[i] = new Library ();
      videos[i].setVideo( number, title, publisher, duration, date  );
      }
      return video;
  }
  </code></pre>
  
  <p>And here is the basic concept for my select and replace function for those who can't figure out what I mean:</p>
  
  <pre><code>public void replaceVideo(Library[] videos, String replaceTo, String replaceWith) 
      {
      for (int i = 0; i &lt; videos.length; i++) 
          if (videos[i].equals(replaceTo)) {
              videos[i]= replaceWith;
          }
      }
  </code></pre>
  
  <p>Simpler solutions will be appreciated. Thanks.</p>