Skip to content

Instantly share code, notes, and snippets.

@geniushkg
Last active August 18, 2016 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geniushkg/6cb904e9d4270e76e411952f383ca8fb to your computer and use it in GitHub Desktop.
Save geniushkg/6cb904e9d4270e76e411952f383ca8fb to your computer and use it in GitHub Desktop.
import java.util.*;
public class QueueSample{
public static void main(String args[]){
Queue<Character> queVar = new LinkList<Character>();
System.out.println("Adding new character to queue.");
queVar.add('A');
que.Var.add('B');
// peek() is used to give first element , will not remove from queue
System.out.println(queVar.peek() + " is First element in que.");
// A is First element in que.
// poll() is used to give first element and removes it from queue
System.out.println(queVar.poll() + "is First element in que." );
// A is First element in que.
System.out.println(queVar.poll() + "is First element in que.");
// B is First element in que.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment