methods and arrays syntax

Page 1 of 1

3 Replies - 328 Views - Last Post: 04 April 2010 - 07:09 PM Rate Topic: -----

#1 paperchacer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 14-March 10

methods and arrays syntax

Posted 02 April 2010 - 09:22 PM

i have been told to create a program that uses two methods to find the minimum and the maximum of a series of numbers from an array. I was wondering if anyone new the syntax of the parameters that would pass the array values to the methods. Thank you!
Is This A Good Question/Topic? 0
  • +

Replies To: methods and arrays syntax

#2 erik.price  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 485
  • View blog
  • Posts: 2,690
  • Joined: 18-December 08

Re: methods and arrays syntax

Posted 02 April 2010 - 09:34 PM

Here's how you allow a method to accept an array as a parameter:
void method(int[] array) { /*implementation*/ }

`method` will now accept any int array passed to it.

To pass an int array to the method:
int[] array = {0,1,2,3,4,5,6,7,8,9};

method(array);
//or
method(new int[]{0,1,2,3,4,5,6,7,8,9});


Was This Post Helpful? 3
  • +
  • -

#3 xor-logic  Icon User is offline

  • HAL9000 was an Apple product
  • member icon

Reputation: 128
  • View blog
  • Posts: 764
  • Joined: 04-February 10

Re: methods and arrays syntax

Posted 03 April 2010 - 01:29 AM

Tutorial: http://www.dreaminco...topic157249.htm
Was This Post Helpful? 0
  • +
  • -

#4 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8343
  • View blog
  • Posts: 31,890
  • Joined: 06-March 08

Re: methods and arrays syntax

Posted 04 April 2010 - 07:09 PM

Everything that has to be said has been said
Topic closed
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1