0

I have the following code in C++:

struct vec3d
{
    float x, y, z;
};

struct triangle
{
    vec3d p[3];
};

struct mesh
{
    vector<triangle> tris;

    bool LoadFromObjectFile(string sFilename) {
        return true;
    }
};

How could I translate this into Java? Would I use classes for that? So in order to group multiple vec3d in a triangle :

public class vec3d  
{
    float x, y, z;
}

public class triangle  
{   
    vec3d[] p = new vec3d[3];
}
Thomas3k24
  • 55
  • 5
  • 1
    Unrelated: I recommend that you not waste too much time trying to use Java the same way you'd use C++. It leads to much pain. In this case there's an easy way out: `public` members, but things often get fugly. – user4581301 Dec 31 '19 at 01:40

1 Answers1

-1

To write a structure in Java, similar would be a class. So yes, you somewhat answered your question.

I believe that this is a better detailed explanation: Creating struct like data structure in Java