| Author |
Arrays
|
Tanuja Vaid
Ranch Hand
Joined: Mar 07, 2002
Posts: 51
|
|
which of the following statements will correcly create and initialize an array of Strings to non null elements?(jq+ question) why is String[]SA=new String[1]{"aaa"}; not valid and String[]SA=new String[1];SA[0]="aaa"; valid Also, I don't understand how below two options are valid too. String[]SA={"aaa"}; String[]SA={new String("aaa")};
|
 |
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
|
|
Hello, Just to point out the obvious... The first one won't compile - so, it's not the right choice. The other three will compile and do what the question is looking to do. Bradley Kjell has a nice on-line Java tutorial that explains many concepts of Java step-by-step. Chapter 46 on Arrays might help you to understand array declaration and initialization better. Good Luck, -Dirk Schreckmann [ March 07, 2002: Message edited by: Dirk Schreckmann ]
|
[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
|
 |
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
|
|
Hello, One more source of good information... From the horse's mouth: http://java.sun.com/docs/books/tutorial/java/data/arrays.html Good Luck, -Dirk Schreckmann
|
 |
 |
|
|
subject: Arrays
|
|
|