Hi,
Java beginner here, moving from C++. What does the bracket mean after a new?
Code:protected String[] name = new String[] {
Integer.toString(1),
Integer.toString(2)
};
Printable View
Hi,
Java beginner here, moving from C++. What does the bracket mean after a new?
Code:protected String[] name = new String[] {
Integer.toString(1),
Integer.toString(2)
};
I assume you mean the curly braces ({}). In the code snippet you posted, they mean initialize the array with the following values.
You don't need new to initialize array like this. And why is that Integer.toString(1) instead of just "1"? The code you posted is equivalent with:Code:protected String[] name={"1","2"};