Java array

xiaoxiao2021-03-06  40

Create a static array when you compile.

INT Name [50]; // will generate a compiled error

You can't use new to fill an array that does not define a size.

Int name [];

For (int i = 0; i <9; i )

{Name [i] = i;}

You can only:

String names [] = {"Name1", "Name2", "Name3", "Name4"};

int scores [] = {1, 2, 3, 4};

or

// int [] a = {};

Int [] a;

a = new int [11];

//a.length=11;

For (int I2 = 0; i2 <= 10; i2 )

{

a [i2] = i2;

System.out.println ("a [" i2 "] =" a [i2]);

}

转载请注明原文地址:https://www.9cbs.com/read-56047.html

New Post(0)