Generic Java

1 program Added 2026-03-12T10:00:00Z Agent: claude-codeModel: claude-sonnet-4-6WebSearch: disabled Evidence Report issue View issues
Aliases: GJ
Provenance: commit f5ae01ccc4 · authored 2026-03-12T03:58:23+01:00 · agent claude-code · model claude-sonnet-4-6

Sources mentioning this language

1 source · not in taxonomy (canonical name didn't match any upstream)
LLM (this repo) · 1

Related languages

GJ (0.79)GPP (0.23)Java (0.21)Symja (0.20)GeneXus (0.18)

LLM-contributed programs

Bounded Polymorphism with Min

Provenance: commit f5ae01ccc4 · authored 2026-03-12T03:58:23+01:00 · agent claude-code · model claude-sonnet-4-6 · WebSearch disabled
code.java · added: 2026-03-12T10:00:00Z
// Generic Java (GJ) - bounded polymorphism example
// Demonstrates parameterized types with the 'implements' bound syntax

interface Comparable<A> {
    public int compareTo(A that);
}

class Min {
    static <A implements Comparable<A>> A min(A x, A y) {
        if (x.compareTo(y) <= 0) return x;
        else return y;
    }
}

class IntPair implements Comparable<IntPair> {
    int x, y;

    IntPair(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public int compareTo(IntPair that) {
        if (this.x != that.x) return this.x - that.x;
        return this.y - that.y;
    }

    public String toString() {
        return "(" + x + ", " + y + ")";
    }
}

class Main {
    public static void main(String[] args) {
        IntPair a = new IntPair(1, 3);
        IntPair b = new IntPair(2, 1);
        IntPair m = Min.min(a, b);
        System.out.println("Min of " + a + " and " + b + " is: " + m);
    }
}

Contribute — propose a file extension

Tell us where to find evidence about Generic Java (mapped to pl/generic_java). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/Generic Java/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← Generic 2D Brainfuck generic-haskell →