title: "Missing return statement" error in Java
body: <p>I don't know what's wrong with this one. I have done this with examples of other codes. And now I'm stuck just because of this single thing.</p>
  
  <pre><code>import java.util.Scanner;
  import java.util.Calendar;
  
  public class Praktikum3
  {
  Scanner scan = new Scanner(System.in);
  Calendar cal = Calendar.getInstance();
  
  String NIP, nama, kelamin, jabat, sub1, sub2, sub3, sub4;
  int a, b, c, d, e, umur, menjabat, tgllhr, blnlhr, thnlhr, lhr, blnjbt, thnjbt, date, month, year;
  
  public Praktikum3() //constructor
  {
      System.out.printf("DATA KARYAWAN\n\n"); //menginisialkan constructor
  }
  
  public void setNama()
  {
      System.out.printf("Nama: " );
      nama = scan.next();
  }
  
  public String getNama()
  {
      return nama;
  }
  
  public void setNIP()
  {
      System.out.printf("NIP : " );
      while (!scan.hasNextLong())
      {
          System.out.printf("!HARUS ANGKA!\n");
          System.out.printf("NIP : ");
          scan.next();
      }
      NIP = scan.next();
  
      if(NIP.length() != 18)
      {
          System.out.printf("!HARUS 18 KARAKTER!\n");
          System.out.printf("NIP : ");
          scan.next();
      }
  
      sub1 = NIP.substring(0,8); /*substring Tanggal lahir*/
      sub2 = NIP.substring(8,14); /*substring Masa menjabat*/
      sub3 = NIP.substring(14,15); /*substring Jenis kelamin*/
      sub4 = NIP.substring(15,18); /*substring Nomor urut*/
  
      date = cal.get(Calendar.DATE);
      month = cal.get(Calendar.MONTH);
      year = cal.get(Calendar.YEAR);
  
      a = Integer.parseInt(sub1.substring(6,8));
      b = Integer.parseInt(sub1.substring(4,6));
      c = Integer.parseInt(sub1.substring(0,4));
  
      d = Integer.parseInt(sub2.substring(4,6));
      e = Integer.parseInt(sub2.substring(0,4));
  }
  
  public String getSub1()
  {
      return sub1;
  }
  
  public String getSub2()
  {
      return sub2;
  }
  
  public String getSub3()
  {
      return sub3;
  }
  
  public String getSub4()
  {
      return sub4;
  }
  
  public int getTgllhr()
  {
      return a;
  }
  
  public int getBlnlhr()
  {
      return b;
  }
  
  public int getThnlhr()
  {
      return c;
  }
  
  public int getUmur()
  {
      tgllhr = date - a;
  
      blnlhr = month - b;
      if(blnlhr &lt; 0)
          lhr = -1;
      else if(tgllhr &lt; 0)
          lhr = -1;
      else
          lhr = 0;
  
      thnlhr = year - c;
  
      umur = thnlhr + lhr;
  
      return umur;
  }
  
  public String getKelamin()
  {
      if(sub3.equals("1"))
          kelamin = "Pria";
      else if(sub3.equals("2"))
          kelamin = "Wanita";
      else
          kelamin = "Ganda";
  }
  
  public int getMenjabat()
  {
      blnjbt = month - d;
      if(blnjbt &lt; 0)
          blnjbt = -1;
      else
          blnjbt = 0;
  
      thnjbt = year - e;
  
      menjabat = thnjbt + blnlhr;
  
      return menjabat;
  }
  
  public static void main(String[]arbi)
  {
      Praktikum3 dt = new Praktikum3();
  
      dt.setNama();
      dt.setNIP();
  
      System.out.printf("\nData\n----\n");
      System.out.printf("Nama          : %s\n", dt.getNama());
      //System.out.printf("NIP           : %s.%s.%s.%s\n", dt.getSub1, dt.getSub2, dt.getSub3, dt.getSub4);
      //System.out.printf("Tanggal lahir : %d-%d-%d\n", dt.getTgllhr, dt.getBlnlhr, dt.getThnlhr);
      System.out.printf("Umur          : %d tahun\n", dt.getUmur());
      System.out.printf("Jenis kelamin : %s\n", dt.getKelamin());
      System.out.printf("Lama menjabat : %d tahun", dt.getMenjabat());
  }
  }
  </code></pre>
  
  <p>This one is in Indonesian. This one I used to practice substring with OOP. Even the get substring method were error.</p>
  
  <p>Error message: </p>
  
  <blockquote>
    <p>Praktikum3.java:125: error: missing return statement }</p>
  </blockquote>