Does Java have an analog of a C++ struct
:
struct Member {
string FirstName;
string LastName;
int BirthYear;
};
I need to use my own data type.
The equivalent in Java to a struct would be
class Member
{
public String FirstName;
public String LastName;
public int BirthYear;
};
and there's nothing wrong with that in the right circumstances. Much the same as in C++ really in terms of when do you use struct verses when do you use a class with encapsulated data.