(Example from another site.)
Line 3: Line 3:
 
Q: How do I initialize and create a list in java? A source code example would be beneficial.
 
Q: How do I initialize and create a list in java? A source code example would be beneficial.
  
A:
+
A: Do you mean an array? Here are some examples from [http://java.sun.com/docs/books/jls/second_edition/html/arrays.doc.html Java's website]
 
+
<source lang=java>
 +
int[] factorial = { 1, 1, 2, 6, 24, 120, 720, 5040 };
 +
char ac[] = { 'n', 'o', 't', ' ', 'a', ' ',
 +
'S', 't', 'r', 'i', 'n', 'g' };
 +
String[] aas = { "array", "of", "String", };
 +
</source>
  
 
----
 
----
  
 
[https://kiwi.ecn.purdue.edu/rhea/index.php/2009_Fall_ECE_462_Lu Back to ECE462]
 
[https://kiwi.ecn.purdue.edu/rhea/index.php/2009_Fall_ECE_462_Lu Back to ECE462]

Revision as of 14:37, 10 September 2009

JAVA FAQ

Q: How do I initialize and create a list in java? A source code example would be beneficial.

A: Do you mean an array? Here are some examples from Java's website

int[] factorial = { 1, 1, 2, 6, 24, 120, 720, 5040 };
char ac[] = { 'n', 'o', 't', ' ', 'a', ' ',
				 'S', 't', 'r', 'i', 'n', 'g' }; 
String[] aas = { "array", "of", "String", };

Back to ECE462

Alumni Liaison

Correspondence Chess Grandmaster and Purdue Alumni

Prof. Dan Fleetwood