以下是C++中的静态结构。如何用Java表示。

static struct {
       int c1;
       int c2;
   } pair[37]= {{3770,3780}, {3770,3781}, {3770,3782}, {3770,3785},
                {3770,3786}, {3770,3787}, {3771,3780}, {3771,3781},
                {3771,3782}, {3771,3785}, {3771,3786}, {3771,3787},
                {3772,3780}, {3772,3783}, {3773,3780}, {3773,3781},
                {3773,3782}, {3773,3785}, {3773,3786}, {3773,3787},
                {3774,3780}, {3774,3781}, {3774,3782}, {3774,3783},
                {3774,3785}, {3774,3786}, {3774,3787}, {3776,3780},
                {3776,3785}, {3776,3786}, {3776,3787}, {53,3770},
                {53,3771},{53,3772},{53,3773},{53,3774},{53,3776}};

谢谢

最佳答案

在Java中,您可以创建对对象的集合/数组,也可以使用多维数组(数组数组);

static int[][] pairs = new int[][] { {3770,3780}, {3770,3781}, {3770,3782}, {3770,3785} }

或者
class Pair {
  int a;
  int b;
  Pair(int a, int b) { this.a=a; this.b=b; }
}

static Pair[] pairs = new Pair[] { new Pair(1,2), new Pair(2,3) ..... }

关于java - 如何用Java表示静态结构,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6072472/

10-13 03:00