@bekti/

JavaClass

Java

https://bekti.net/blog/object-dan-class-di-java-dan-cara-membuatnya/

fork
loading
Files
  • Main.java
  • Karyawan.java
  • Orang.java

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.5114083056663596","path":"Main.java","file":{"path":"Main.java","content":{"asEncoding":{"base64":"Y2xhc3MgTWFpbiB7CiAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgCiAgICAgIE9iamVjdCBvYmplY3QgPSBuZXcgT2JqZWN0KCk7CiAgICAgIG9iamVjdCA9IG5ldyBTdHJpbmcoInRleHQiKTsKICAgICAgU3lzdGVtLm91dC5wcmludGxuKG9iamVjdCk7CiAgICAgIG9iamVjdCA9IChJbnRlZ2VyKSAyOwogICAgICBTeXN0ZW0ub3V0LnByaW50bG4ob2JqZWN0KTsKICAgICAgb2JqZWN0ID0gKERvdWJsZSkgNS4wOTMyOwogICAgICBTeXN0ZW0ub3V0LnByaW50bG4ob2JqZWN0KTsKICAgICAgb2JqZWN0ID0gKEJvb2xlYW4pIHRydWU7CiAgICAgIFN5c3RlbS5vdXQucHJpbnRsbihvYmplY3QpOwoKICAgIE9yYW5nIGlkbyA9IG5ldyBPcmFuZygiMDAxIiwiSWRvIiwxOSk7CgogICAgU3lzdGVtLm91dC5wcmludGxuKCJcbj09PT09IERhdGEgT3JhbmcgPT09PT0iKwogICAgICAiXG5JRCA6IiArIGlkby5nZXRJZCgpICsKICAgICAgIlxuTmFtYSA6IiAraWRvLmdldE5hbWEoKSsKICAgICAgIlxuVW11ciA6IiAraWRvLmdldFVtdXIoKSsKICAgICAgIlxuUGVya2VuYWxhbiA6Iik7CiAgICAgIGlkby5rZW5hbGFuKCk7CiAgICAKICAgIEthcnlhd2FuIGRyaW9uYSA9IG5ldyBLYXJ5YXdhbigiMDAxIiwgIkRyaW9uYSIsIDIzLCAic3VwZXJ2aXNvciIpOwoKICAgIFN5c3RlbS5vdXQucHJpbnRsbigiXG49PT09PSBEYXRhIGthcnlhd2FuID09PT09IisKICAgICAgIlxuSUQgOiIgKyBkcmlvbmEuZ2V0SWQoKSArCiAgICAgICJcbk5hbWEgOiIgK2RyaW9uYS5nZXROYW1hKCkrCiAgICAgICJcblVtdXIgOiIgK2RyaW9uYS5nZXRVbXVyKCkrCiAgICAgICJcbkphYmF0YW4gOiIgK2RyaW9uYS5nZXRKYWJhdGFuKCkrCiAgICAgICJcblBlcmtlbmFsYW4gOiIpOwogICAgICBkcmlvbmEua2VuYWxhbigpOwogICAgICAKCiAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiXG5cbiIrZHJpb25hLmdldEphYmF0YW4oKSk7Ly9tZW5nYWtzZXMgamFiYXRhbiBvYmplY3QgbWVuZ2d1bmFrYW4gZnVuZ3NpCiAgICAgIC8vIGphYmF0YW4gZHJpb25hIGFkYWxhaCAic3VwZXJ2aXNvciIKCiAgICAgIGRyaW9uYS5zZXRKYWJhdGFuKCJtYW5hZ2VyIik7IC8vIG1lbmd1YmFoIGphYmF0YW4gb2JqZWN0IG1lbmdndW5ha2FuIGZ1bmdzaQogICAgICAvLyBzZWthcmFuZyBqYWJhdGFuIGRyaW9uYSBhZGFsYWggIm1hbmFnZXIiIGRpIGthbnRvciBjYWJhbmcgcGVydXNhaGFhbiAKCiAgICAgIGRyaW9uYS5rZW5hbGFuKCk7Ly9tZW1hbmdnaWwgYWtzaSBwZXJrZW5hbGFuIHlhbmcgbWlzYWxueWEgYWthbiBkaWxha3VrYW4gZGkga2FudG9yIGNhYmFuZwoKICB9Cn0="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class Main {
  public static void main(String[] args) {
    
      Object object = new Object();
      object = new String("text");
      System.out.println(object);
      object = (Integer) 2;
      System.out.println(object);
      object = (Double) 5.0932;
      System.out.println(object);
      object = (Boolean) true;
      System.out.println(object);

    Orang ido = new Orang("001","Ido",19);

    System.out.println("\n===== Data Orang ====="+
      "\nID :" + ido.getId() +
      "\nNama :" +ido.getNama()+
      "\nUmur :" +ido.getUmur()+
      "\nPerkenalan :");
      ido.kenalan();
    
    Karyawan driona = new Karyawan("001", "Driona", 23, "supervisor");

    System.out.println("\n===== Data karyawan ====="+
      "\nID :" + driona.getId() +
      "\nNama :" +driona.getNama()+
      "\nUmur :" +driona.getUmur()+
      "\nJabatan :" +driona.getJabatan()+
      "\nPerkenalan :");
      driona.kenalan();
      

      System.out.println("\n\n"+driona.getJabatan());//mengakses jabatan object menggunakan fungsi
      // jabatan driona adalah "supervisor"

      driona.setJabatan("manager"); // mengubah jabatan object menggunakan fungsi
      // sekarang jabatan driona adalah "manager" di kantor cabang perusahaan 

      driona.kenalan();//memanggil aksi perkenalan yang misalnya akan dilakukan di kantor cabang

  }
}