Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

for loop construct with array  RSS feed

 
Greenhorn
Posts: 21
  • 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 ]
 
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.
 
Java Cowboy
Sheriff
Posts: 16084
88
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 ]
 
David Gill
Greenhorn
Posts: 21
  • 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 =)
 
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 !
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!