title: An object wont let me specified a particular variable - Java
body: <p>I'm a new learner in java and created my own program to practice and upskill myself. But I have a problem that states [incompatible types: String cannot be converted to Friend] in which I'm having a hard time to figure out why the specific object wont let me specified variable like &quot;friend.name[i]&quot;  Is my logic wrong? How can I fix this? Here's my code:</p>
  <p>Main:</p>
  <pre><code>package Friendprogram;
  import Libraries.*;
  import java.util.Scanner;
  
  public class forfunportfolio {
      public static void main(String[] args) {
          
          Squad gang = new Squad (&quot;Thunder&quot;, 3, 15, 18);
          Friend [] friend = new Friend [gang.maxSlot]; 
          Scanner input = new Scanner(System.in);
  
                     for(int i=0; i&lt;gang.maxSlot; i++){ 
                                                      
                         System.out.printf(&quot;Enter Name:&quot;);
                         String tmpName = input.next();
                         friend[i] = tmpName; 
                         System.out.println(&quot;Enter Age:&quot;);
                         int tmpAge = input.nextInt();
                         friend[i] = tmpAge; 
                     }   
                     for(Friend f: friend){
                         gang.Agechecker(f); 
                         gang.newFriend(f); 
                     }
                  break;
      }
  }
  </code></pre>