-
August 5th, 2005, 12:24 PM
#1
what does this mean? new String() {...}
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)
};
-
August 5th, 2005, 03:59 PM
#2
Re: what does this mean? new String() {...}
I assume you mean the curly braces ({}). In the code snippet you posted, they mean initialize the array with the following values.
Hungarian notation, reinterpreted? http://www.joelonsoftware.com/articles/Wrong.html
-
August 6th, 2005, 04:58 AM
#3
Re: what does this mean? new String() {...}
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"};
"Programs must be written for people to read, and only incidentally for machines to execute."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|