Hi all,
I would have a question.
I know that I should (or must) respect the encapsulation rule (as one of the main three Java features) but what about if I have some "Data Structure"? I mean something like "struct" in C/C++.
So if my class contains only data (not methods), is it "appropriate" to make that data (variables) public?
Example:
class Point
{
// Fields
public int x;
public int y;
// Constructor
public Point(int x, int y)
{
this.x = x;
this.y = y;
}
}
Thanks.