title: How to call an Object Method in Java
body: <p>I've looked all over the internet, but I can't figure out what I'm doing wrong. I'm trying my hand at using private variables from another class using get/set methods. Something's going wrong, but I can't figure it out.</p>
  
  <pre><code>public class Character
  {
     private int atk = 0;
     private int def = 0;
     private int spd = 0;
  
     public void setStat(String stat, int n)
     {
        stat = stat.toLowerCase();
  
        if(stat.equals("def") || stat.equals("defence") || stat.equals("defense"))
        {
           def = n;
        }
        if(stat.equals("atk") || stat.equals("attack"))
        {
           atk = n;
        }
        if(stat.equals("spd") || stat.equals("speed"))
        {
           spd = n;
        }
     }
  
     public int getStat(String stat)
     {
         stat = stat.toLowerCase();
         int n = -1;
         if(stat.equals("def") || stat.equals("defence") || stat.equals("defense"))
         {
            n = def;
         }
         if(stat.equals("atk") || stat.equals("attack"))
         {
            n = atk;
         }
         if(stat.equals("spd") || stat.equals("speed"))
         {
            n = spd;
         }
         return n;
     }
     public Character(int a, int d, int c)
     {
        atk = a;
        def = d;
        spd = c;
     }
  }
  </code></pre>
  
  <p>This is my first class, <code>Character</code> which will be used as the template for the object, complete with get/set methods.</p>
  
  <pre><code>public class newCharacters
  {
     Character person1 = new Character(2, 4, 3);
     person1.getStat("atk");
  }
  </code></pre>
  
  <p>This is my second class, which constructs a character object and then tries to get a variable. Problem is, whenever I compile, it says that the object method needs an identifier. Exact quote: <code>&lt;identifier&gt; expected</code></p>
  
  <p>I can't figure out what it means, or what I'm doing wrong? I made get/set methods for each class, created the object in both classes, even constructed and called the object method within the <code>Character</code> class. Same problem every time. Can someone help?</p>