I hear all the time people complaining about Java. One common complain is that in Java "need to write a lot of things". And why Java does not have structs like C.

Today i was refining the FIRE/J engine, simplifying its API a little. While i was implementing the MatchResult class i needed a "struct". And voila ..
package org.fire.regexp;

public class MatchResult {
    int groupCount;
    Group[] groups;
    CharSequence data; 
    MatchResult(CharSequence data, int groupCount) {
        this.groupCount = groupCount;
        this.groups = new Group[groupCount];
        for(int i = 0;i < groupCount;i++) {
        	groups[i] = new Group();
    public int end() {
        return groups[0].end;

    public int end(int group) {
        return groups[group].end;

    public String group() {
        return data.subSequence( groups[0].start, groups[0].end).toString();

    public String group(int group) {
        return data.subSequence( groups[group].start, groups[group].end).toString();

    public int groupCount() {
        return groupCount;

    public int start() {
        return groups[0].start;

    public int start(int group) {
        return groups[group].start;

class Group {
    int start;
    int end;
    Group() {
    	start = 0;
    	end = 0;
Class Group is the struct we all looking for. You dont need to provide setters and getters ... (and write lots of code) just dont add any modifier in front of the variable and you get package access.

In fact, the ommited code in class group contains a default constructor that initializes start and end with their default values. Elementary ... at least.