• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

for loop construct with array

 
Ashlon Hill
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the following code, is double[] an array or what would you call it if you were talking about it? thanks



public double sum(double[] list) {
double s = 0;
for (int i=0; i < list.length; ++i)
s += list[i]
total = total + list[i]
return s;
}
[ October 25, 2007: Message edited by: Ash Hill ]
 
sarvesh meens
Ranch Hand
Posts: 43
Firefox Browser Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ofcourse, it is an array.
A double array to be precise.

It's a double array that is passed as a parameter to a method.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See: The Java Tutorial - Arrays

Please use a meaningful subject line instead of "simple question" when you post a question. Imagine what the forum would look like if everybody used "Help!!!", "Question..." etc. as the subject...
[ October 22, 2007: Message edited by: Jesper Young ]
 
Ashlon Hill
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I will keep that in mind next time. I learn from my mistakes =)
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have made plenty of them.

1. An array is considered an object in java.
2. If it looks like an array, it is an array.
3. Arrays look like [].
4. You might say an array of " ... "
5. In this example, if you said and array of doubles, folks should grasp what it is you are talking about.
6. I think you can change your own subject line, I am not sure. Use the pencil and paper icon, see what happens.



:it compiled !
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic