jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes for loop construct with array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "for loop construct with array" Watch "for loop construct with array" New topic

for loop construct with array

David Gill

Joined: Feb 24, 2005
Posts: 19
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

Joined: Mar 31, 2006
Posts: 43

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

Joined: Aug 16, 2005
Posts: 14993

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 ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
David Gill

Joined: Feb 24, 2005
Posts: 19
Thanks, I will keep that in mind next time. I learn from my mistakes =)
Nicholas Jordan
Ranch Hand

Joined: Sep 17, 2006
Posts: 1282
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 !

"The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
I agree. Here's the link: http://aspose.com/file-tools
subject: for loop construct with array
It's not a secret anymore!