Reputation: 1883
Is there a short hand for defining the access modifiers of a classes fields and methods? More in a C++ style, I've searched but keep coming up with sites explaining what the purpose of each modifier is rather than a short hand.
public class myNum {
public int getNum() { return 0; }
public void setNum(int n) { int num = n; }
private int num;
private String value;
}
Could become
public class myNum {
public:
int getNum() { return 0; }
void setNum(int n) { int num = n; }
private:
int num;
String value;
}
Upvotes: 1
Views: 162
Reputation: 1191
Although there is no short for defining methods, Eclipse can automatically generate getter and setter methods for you.
Upvotes: 0
Reputation: 10995
For methods nope. For variables you could try
public int n1,n2,n3..n;
private int n1,n2,n3..n;
But as you can see it can become messy quickly. And even then, it doesn't allow for different types under one access modifier.
But really nope.
Upvotes: 2