0
var Var1 = ["0"];
var Var2 = ["0"];
var Var3 = ["0"];
var Var4 = ["0"];

How can i form this type of variables in java. This is of JavaScript. I tried something like this, but fail.

Array Var1[] = new["0"];
4

1 回答 1

4

The syntax differs for Java:

String[] var1 = { "0" };

You can also do this:

String[] var1 = new String[] { "0" };

although the second String[] is optional in the array declaration.

Also

int[] var1 = { 0 };

for integer types.

See: Arrays

于 2012-11-01T13:07:04.140 回答