2 Replies - 466 Views - Last Post: 02 July 2015 - 09:34 AM Rate Topic: -----

#1 mgrex   User is offline

  • D.I.C Regular

Reputation: 3
  • View blog
  • Posts: 281
  • Joined: 25-March 10

Pass 2 arrays to a method,Cannot make a static reference to ..

Posted 02 July 2015 - 08:50 AM

I marked the error in line 14:

Spoiler


The other examples I came only deals with passing a single array argument.

Is This A Good Question/Topic? 0
  • +

Replies To: Pass 2 arrays to a method,Cannot make a static reference to ..

#2 ChrisNt   User is offline

  • cute bug

Reputation: 262
  • View blog
  • Posts: 896
  • Joined: 31-July 13

Re: Pass 2 arrays to a method,Cannot make a static reference to ..

Posted 02 July 2015 - 09:00 AM

You are trying to call a non static method from your main method ,to do so you have to make your method static or create an object of that class and call the method.

This post has been edited by ChrisNt: 02 July 2015 - 09:01 AM

Was This Post Helpful? 1
  • +
  • -

#3 mgrex   User is offline

  • D.I.C Regular

Reputation: 3
  • View blog
  • Posts: 281
  • Joined: 25-March 10

Re: Pass 2 arrays to a method,Cannot make a static reference to ..

Posted 02 July 2015 - 09:34 AM

View PostChrisNt, on 02 July 2015 - 11:00 AM, said:

You are trying to call a non static method from your main method ,to do so you have to make your method static or create an object of that class and call the method.



This is why I created the following in line 12:
Ch_05_01_ControlStructures Pass1 = new Ch_05_01_ControlStructures();

Awesome, that seemed to do the trick.

The following worked:
Pass1.avgSalesStaff(sales2014, staff2014);

The following did not:
Pass1.avgSalesStaff(sales2014[], staff2014[]);

To do the static method way:

avgSalesStaff(sales2014, staff2014);
static void avgSalesStaff (int[] sales, int[] staff)

Thank your for the assistance.

This post has been edited by mgrex: 02 July 2015 - 09:46 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1