import java.io.InputStreamReader;
import java.io.IOException;
import java.util.LinkedList;
import java.util.Queue;
public class CobaQueue
{
private static int Ukuran;
private static Queue
public static void main(String[] args)
{
BuatQueue();
BacaData();
TulisData();
}
private static void BuatQueue()
{
NewQueue = new LinkedList
}
private static int InputData()
{
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
String AngkaInput = null;
try
{
AngkaInput = bfr.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
int Data = Integer.valueOf(AngkaInput).intValue();
return Data;
}
private static void BacaData()
{
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
String NewData = null;
String StringInput = null;
int data;
for (int i = 0; i < 8; i++) {
System.out.print("Data ke-" + (i + 1) + " : ");
try
{
StringInput = bfr.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
NewData = String.valueOf(StringInput);
NewQueue.add(NewData);
}
data = NewQueue.size();
System.out.println("Ukuran QUEUE sekarang adalah " + data);
}
private static void TulisData()
{
int data;
String NewData = null;
System.out.println("\nUrutan keluar elemen dari QUEUE : ");
for (int i = 0; i < 8; i++)
{
NewData = NewQueue.remove();
System.out.println("Data ke-" + (i + 1) + " : " + NewData);
}
data = NewQueue.size();
System.out.println("Ukuran QUEUE sekarang adalah " + data);
}
}
Sekedar mampir supaya dimampiri
BalasHapus