Skip to main content

QUEUE In Java Programing

This posting is about QUEUE Script in JAVA Programing



QUEUE in java adalah materi yang mempelajari tentang antrian data yang di buat dengan menggunakan pemrograman java, Queue memiliki beberapa method yang di gunakan untuk melakukan operasi dalam berjalannya program, methodnya yaitu : 

- Insert
- Remove
- Penentuan jumlah antrian
- View

pada script queue terdapat banyak versi seperti menggunakann class variable, menggunakan array, menggunakan database dll.

pada kali ini saya akan membahas tentang QUEUE menggunakan versi Array. Queue pada versi ini memiliki beberapa versi juga. ada yang menggunakan 1 array, 2 array, ataupun array 2 dimensi. pada script yang akan di bahas ini adalah menggunakan script 2 array.

berikut script nya :

1. class atrian :


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package queue;

/**
 *
 * @author bill
 */
public class antrian {
   public int angka1=0,angka2=0,angka3=0,maxsize=5,masuk=0,hapus=0;
   public int antri[] = new int[maxsize];
   public int keluar[]= new int[maxsize];
    antrian next;
  public void antricoy(int maxsize){
   
       this.maxsize = maxsize;
    }
    public void insert(int angka){
        try{
    if(maxsize!=masuk){
        antri[masuk]=angka;
       masuk++;
    }else{
        System.out.println("Full!! > "+angka);
        System.out.println("==================");
    }
     }catch(Exception e){
         System.out.println("error");
   
     }
    }
     public void remove(int angka){
         for(int i=0;i<maxsize;i++){
          if(antri[i]==angka){
              antri[i]=0;
              keluar[i]=angka;
          }
         }
     }
 
 
    public void tampil(){
        for(int i=0;i<this.maxsize;i++){
            if(0==antri[i]){
                System.out.println("Remove : "+keluar[i]);
            }else{
            System.out.println("Queue : "+antri[i]);
            System.out.println("-----------------");
            }
        }
    }
}


2. class main :

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package queue;

/**
*
* @author bill
*/
public class main {
public static void main(String[] args) {
antrian bill = new antrian();
bill.antricoy(3);
bill.insert(2);
bill.insert(4);
//bill.insert(6);
bill.insert(1);
bill.remove(4);
bill.remove(1);
bill.remove(2);
bill.tampil();

}
}




Mau pasang iklan di blog?. klik Disini
Sekian artikel saya, Semoga Bermanfaat.

Stay fools to Stay Hungry
NB : Artikel ini di peruntukkan untuk pendidikan semata. hal-hal negatif yang di lakukan oleh pengguna tutorial , bukan tanggung jawab penulis.

Popular posts from this blog

The Advantage of Using HTTP Default Authorization Scheme #DigitalSecurity

pixabay.com Hello Everyone, This day I would like to introduce you to the default header for authorization in HTTP. HTTP auth scheme is a guide or standardization scheme for the authorization header in the HTTP protocol. this standard is using key Authorization in the header and followed by a value that usually filled by key or token. for example : Authorization : <type> <key/token> this standard is the solution of the key header for authorization that really random was provided by developers to build an authorization header for their application, in my experience, developers used to "token" for their key in the header that usually followed by the hash value. the random key makes developers using more time for writing code for getting header key and validating the value which is you could use the library and focus on writing the logic of your application. Depend on Mozilla site , HTTP auth scheme divided by 4 types, such as : Basic  (see  RF

Typer shark Deluxe free full crack

Typer shark Deluxe : software yang akan membantu kita untuk belajar mengetik keyboard dengan cara 10jari, untuk agan2 yang baru belajar komputer pasti teknik pertama yang dilakukan adalah dengan 11jari (kanan 1 + kiri 1 = 11)hahahaha, softaware ini sangat menarik, karna kita belajar 10jari dengan bermain game.. n gamenya interaktif,,, pkoqnya yang tadinya mengetik 11jari, dalam waktu seminggu pasti bisa lancar 10jari... syaratnya harus tekunn...  kalo agan mau ngunduh silahkan : Download screenshot:

Automatic API Documentation Swagger in Golang #GolangDev

pixabay.com In this article, I'll explain how to generate an API blueprint instantly using SwagGo in Golang. API blueprint is a document that contains a bunch of API endpoints, its slickly same as documentation but less description, it's allow another programmer to read and see all the available endpoint and try it out with sandbox feature. Swagger is one of the most used API blueprints right now, it's available in free but limited usage. if you wanna use the free credit, you need to understand YAML notation, you can read the example notation in swagger official documentation. but again, it's really hard and takes an expensive time to arranges all the notation to achieve a good API blueprint. fortunately, there are tools in Golang that allow us to generate the YAML notation and automatically generate the blueprint page with only using markup notation, and it's FREE unlimited for self-host, insane right? SwagGo tools are available here , the documentation is very cl