Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 12th, 2007, 08:34 AM
Registered User
 
Join Date: Feb 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Returning the Index number of an array

How do I return the number of the month with the highest rainfall... in this case [3].
I can easily return the value of [3] but I need to return the index number itself in a private method.
The code of my constuctor is below...

Many thanks on what i'm sure is an easy problem!



// constructor
 public Rainfall()
    {
        manchesterRain = new double[12];

        manchesterRain[0] = 187.3;
        manchesterRain[1] = 234.4;
        manchesterRain[2] = 219.9;
        manchesterRain[3] = 323.7;
        manchesterRain[4] = 256.7;
        manchesterRain[5] = 164.2;
        manchesterRain[6] = 126.6;
        manchesterRain[7] = 98.6;
        manchesterRain = 149.0;
        manchesterRain[9] = 198.9;
        manchesterRain[10] = 254.7;
        manchesterRain[11] = 221.5;
    }

 
Old February 13th, 2007, 05:54 AM
Registered User
 
Join Date: Feb 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

use a for loop like this

for(int i=0;i<arr.lenth;i++){

// u get i here

}






Similar Threads
Thread Thread Starter Forum Replies Last Post
Function returning an array rfstuck Pro VB 6 5 March 12th, 2008 07:35 AM
Returning current page number Larry Landis Word VBA 1 January 26th, 2007 09:23 AM
Why is DataRow returning 1 more index rsearing ASP.NET 2.0 Basics 1 January 14th, 2007 02:18 AM
All Array is not returning [Coding Error] vinod_yadav1919 Javascript How-To 0 January 18th, 2005 10:10 AM
Returning index values from an associated array Jams30 BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 4 October 7th, 2003 11:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.