I’d like to avoid the repetitious code-bloat and typing tedium of defining “C-struct-like” classes like:
class Foo {
int x;
float y;
String z;
public Foo(int x, float y, String z) {
this.x = x;
this.y = y;
this.z = z;
}
}
? E.g. are there any Eclipse tricks that may be helpful here?
To see what I mean by “code-bloat”, compare the above with what it takes to define the corresponding struct in C:
struct foo {
int x;
float y;
char *z;
}
Each member field is mentioned only once, whereas in the Java code it needs to be mentioned three times (one of them in the form of the corresponding constructor argument).
In eclipse you can right click in java editor, source -> generate constructors using fields.
I guess that is what you are looking for.