Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
org.apache.commons.collections4.queue.CircularFifoQueue Example
What is org.apache.commons.collections4.queue.CircularFifoQueue class? How to use org.apache.commons.collections4.queue.CircularFifoQueue class?
✍: FYIcenter.com
org.apache.commons.collections4.queue.CircularFifoQueue class is a Java class
offered in commons-collections4.jar that
represents a first-in first-out queue with a fixed size that replaces its oldest element if full.
Here is a simple example of using org.apache.commons.collections4.queue.CircularFifoQueue class:
// Copyright (c) 2016-2018 FYIcenter.com
// Supports commons-collections4-4.2
// Supports commons-collections4-4.1
import org.apache.commons.collections4.queue.CircularFifoQueue;
// Example of using the CircularFifoQueue class
public class CircularFifoQueueExample {
public static void main(String[] args) throws Exception {
// Create a CircularFifoQueue object
CircularFifoQueue<String> week = new CircularFifoQueue<String>(7);
// Load the CircularFifoQueue object to the full size
week.add("Sunday");
week.add("Monday");
week.add("Tuesday");
week.add("Wednesday");
week.add("Thursday");
week.add("Friday");
week.add("Saturday");
// Load more elements
week.add("One");
week.add("Two");
week.add("Three");
// Poll elements out of the CircularFifoQueue object
for (int i=0; i<10; i++) {
System.out.println(i+ ": "+week.poll());
}
}
}
You can compile and run the above example in a command window as shown below:
C:\fyicenter>\fyicenter\jdk-1.8.0\bin\javac -cp C:\fyicenter\commons-collections4-4.2\commons-collections4-4.2.jar CircularFifoQueueExample.java C:\fyicenter>\fyicenter\jdk-1.8.0\bin\java -cp .;C:\fyicenter\commons-collections4-4.2\commons-collections4-4.2.jar CircularFifoQueueExample 0: Wednesday 1: Thursday 2: Friday 3: Saturday 4: One 5: Two 6: Three 7: null 8: null 9: null
⇒ org.apache.commons.collections4.bag.HashBag Example
⇐ org.apache.commons.collections4.map.LazyMap Example
2017-05-20, ∼3161🔥, 0💬
Popular Posts:
What Is mail.jar of JavaMail 1.4? I got the JAR file from javamail-1_4.zip. mail.jar in javamail-1_4...
What Is HttpComponents httpclient-4.2.2.jar? HttpComponents httpclient-4.2.2.jar is the JAR file for...
JDK 11 jdk.crypto.ec.jmod is the JMOD file for JDK 11 Crypto EC module. JDK 11 Crypto EC module comp...
ANTLR is a powerful parser generator for multiple programming languages including Java. ANTLR contai...
Woodstox 6.4.0 Source Code Files are provided at the Woodstox GitHub Website . You can download them...