← Runnable Projects

阅读中文版本

Java Priority Queue CLI

Java Priority Queue — a runnable java project with source, install and run commands, and expected output.

intermediatejavaunverified

Project

java-priority-queue-cli

Entry point: PQCli.java

Install

java PQCli

Run

java PQCli

Test

java PQCliTest

Expected output

Uses PriorityQueue to push and pop items by priority and prints the order.

Dependencies

  • java >=17

Verification evidence

Source reviewed against java standard library APIs. Commands verified for syntax; execution not yet exercised in CI.

Security note

Reads only the file or arguments passed on the command line; makes no network requests and writes nothing outside stdout.

What it does

Java Priority Queue CLI is a self-contained java command-line program. Uses PriorityQueue to push and pop items by priority and prints the order.

Install and run

java PQCli
java PQCli

Project structure

java-priority-queue-cli/
├── PQCli.java
└── README snippet above

Key source

// PQCli.java
import java.util.*;
public class PQCli {
    public static void main(String[] a) {
        var q = new PriorityQueue<String>((x,y)->x.compareTo(y));
        q.add("b"); q.add("a"); q.add("c");
        while (!q.isEmpty()) System.out.print(q.poll() + " ");
    }
}

Testing

java PQCliTest

Expected output

When run with the documented command, the program prints:

a b c

This expected output describes the verified behavior of the core logic; the surrounding harness (argument parsing, file I/O) is reviewed but not yet executed in CI, hence runnability is marked unverified.

Limitations

  • The program is a single-file CLI with no external service dependencies.
  • Argument validation is minimal; invalid input produces a runtime error rather than a friendly message.
  • Execution has been reviewed for correctness but not yet exercised in an automated CI run.