title: Replace object element in array of objects if match found in java
body: <p>In the code below the method will take array of 5 Library objects and one Library object as input. I would like  to replace the Library object if for the id of the object an object with same id is found in the array. The output will return true and print the 5 objects with the replaced object values. Else return false and print the array as it is.
  <br>
  For example:
  If library object input is <code>18,rmgjynm,qxkhlbb</code>
  Output will be <br></p>
  
  <pre><code>Output for performing replace is: false 
  33 drfnfuk cqisthj 
  78 xhzebcf nnpwbrf 
  68 qnoquku qstcebj 
  81 ghgwsjm xlewgbj 
  47 wgioqsg vjtwscm
  </code></pre>
  
  <p>i.e no changes are made<br>
  If library object input is <code>47,tvistro,rnpholx</code><br></p>
  
  <pre><code>Output for performing replace is: true
  33 drfnfuk cqisthj 
  78 xhzebcf nnpwbrf 
  68 qnoquku qstcebj 
  81 ghgwsjm xlewgbj 
  47 tvistro rnpholx 
  </code></pre>
  
  <p>The code I've written till now is as shown below. Please suggest changes as the code shows error of Cannot find symbol for inputlib elements.
  </p>
  
  <pre><code>public class LibraryDemo 
  {
  public static Library[] replaceLibraryById(Library[] objArray, Library inputlib)
  {
      for(int i=0;i&lt;objArray.length;i++)
      {
          if(inputlib.inputid==objArray[i].id)
          {
              objArray[i].setName=inputlib.inputname;
              objArray[i].setAddress=inputlib.inputadd;
              boolean tf=true;
              System.out.print("Output for performing replace on libraryRes1 is"+tf);
              for(Library:objArray)
              {
                  System.out.println(library.getId()+" " + library.getName()+" " + library.getAddress()+" ");
              }
              break;
          }
          else
          {
              boolean tf=false;
              System.out.print("Output for performing replace on libraryRes1 is"+tf);
              for(Library:objArray)
              {
                  System.out.println(library.getId()+" " + library.getName()+" " + library.getAddress()+" ");
              }
          }
      }
      return replaceLibraryById();
  }
  public static void main(String args[]) 
  {
      Scanner sc=new Scanner(System.in);
      Library[] objArray=new Library[5];
  
      for(int i=0;i&lt;objArray.length;i++)
      {
          int id=sc.nextInt();sc.nextLine();
          String name=sc.nextLine();
          String address=sc.nextLine();
          objArray[i]=new Library(id,name,address);
      }
  
      int inputid=sc.nextInt();sc.nextLine();
      String inputname=sc.nextLine();
      String inputadd=sc.nextLine();
      Library inputlib=new Library(inputid,inputname,inputadd);
      replaceLibraryById(objArray, inputlib);
  }
  }
  
  class Library
  {
  int id;
  String name;
  String address;
  
  public int getId()
  {
      return id;
  }
  public void setId(int id)
  {
      this.id=id;
  }
  public String getName()
  {
      return name;
  }
  public void setName(String name)
  {
      this.name=name;
  }
  public String getAddress()
  {
      return address;
  }
  public void setAddress(String address)
  {
      this.address=address;
  }
  
  
  public Library(int id,String name, String address)
  {
      this.id=id;
      this.name=name;
      this.address=address;
  }
  }
  </code></pre>