title: Is it possible to create a generic method that is suitable for different classes in Java?
body: <p>I have different classes that have a structure like this:</p>
  
  <pre><code>public class MyClass {
      private String name;
      private List&lt;International&gt; internationalList;
  }
  </code></pre>
  
  <p>What I want is to have a generic method that given a localization (example: "en-us") it searches at the internationalList and set the name with the correct language.  </p>
  
  <p>Example: </p>
  
  <pre><code> public MyClass myMethod(String local, MyClass object){
  
              for (International international : object.internationalList){
                  if(local.equals(international.language)){
                 object.name = international.translation
           }
        }
      return myObject;
   }
  </code></pre>
  
  <p>I didn't want to re-write this code to every class. Is it possible to create a generic method that is suitable for all classes that have this structure?</p>