You may declare a public class with public members:
Code:
public class Employee;
{
public int id;
public String name;
public int department;
}
but only in rare cases you will find such a design in professional code.
I wouldn't call it an equivalent to C, because the principals of an OO-Language are different from C, and you can't translate concepts from one to the other.
If you're trying to build some kind of data container object, in Java you usually define the members as private variables with public get and set methods.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.