java 2차원 그룹을 정의하는 몇 가지 쓰기 (소결)

다음과 같습니다.
// 1 
class numthree
{
public static void main(String[] args)
{
float[][] numthree;       // float 2 
numthree=new float[5][5];    // 5 5 
numthree[0][0]=1.1f;      //    1 1 =1.1
numthree[1][0]=1.2f;                 // 2 1 =1.2
numthree[2][0]=1.3f;                 // 3 1 =1.3
numthree[3][0]=1.4f;                 // 4 1 =1.4
numthree[4][0]=1.5f;                 // 5 1 =1.5
System.out.println(numthree[0][0]); // 
System.out.println(numthree[1][0]);
System.out.println(numthree[2][0]);
System.out.println(numthree[3][0]);
System.out.println(numthree[4][0]);
}
}

// 2   
class numfour
{
public static void main(String[] args)
{
  short[][] numfour=new short[5][8]; // short 5 8 
  numfour[0][7]=10;
  numfour[1][6]=20;
  numfour[2][5]=30;
  numfour[3][4]=40;
  numfour[4][3]=50;
  System.out.println(numfour[0][7]);
  System.out.println(numfour[1][6]);
  System.out.println(numfour[2][5]);
  System.out.println(numfour[3][4]);
  System.out.println(numfour[4][3]);
}
}

// 3     
class numfive
{
public static void main(String[] args)
{
long[][] numfive=new long[5][];   // long 
numfive[0]=new long[5];       // 1 5 
numfive[1]=new long[6];       // 2 6 
numfive[2]=new long[7];       // 3 7 
numfive[3]=new long[8];       // 4 8 
numfive[4]=new long[9];       // 5 9 
numfive[0][4]=10000000000L;     //1 5 =10000000000
numfive[1][5]=20000000000L;     //2 6 =20000000000
numfive[2][6]=30000000000L;     //3 7 =30000000000
numfive[3][7]=40000000000L;     //4 8 =40000000000
numfive[4][8]=50000000000L;     //5 9 =50000000000
System.out.println(numfive[0][4]); // 
System.out.println(numfive[1][5]);
System.out.println(numfive[2][6]);
System.out.println(numfive[3][7]);
System.out.println(numfive[4][8]);
System.out.println(numfive[4][7]); //  Java 0
}
}

// 2 4   
class numsix
{
public static void main(String[] args)
{
double[][] numsix={{1.111D,2.222D,3.333D},{4.444D,5.555D,6.666D}};// double 3 3 
System.out.println(numsix[0][0]); // 1 1 =1.111
System.out.println(numsix[1][1]); // 2 2 =5.555
}
}

// 2 5   2 
class numseven
{
public static void main(String[] args)
{
int[][] numseven=new int[][]{{10,20,30},{40,50},{60}}; //   !
System.out.println(numseven[0][2]);
System.out.println(numseven[1][1]);
System.out.println(numseven[0][0]);
}
}

// 2 6  2 ;
class numeight
{
public static void main(String[] args)
{
int[][] numeight={{100,200,300,400},{500,600,700,800},{900,1000,1100,1200,1300}};
System.out.println(numeight[0][2]);
System.out.println(numeight[1][2]);
System.out.println(numeight[2][1]);
}
}
이상은 여러분이 가져온 자바가 2차원 그룹을 정의하는 몇 가지 작법(소결)의 전체 내용입니다. 많은 응원 부탁드립니다~

좋은 웹페이지 즐겨찾기