Results 1 to 5 of 5
  1. #1
    bside is offline Member
    Join Date
    Sep 2011
    Posts
    3
    Rep Power
    0

    Default Question about tester

    If i have the next method:

    Java Code:
        public void changer(int[] x, int y) 
          {  
            x[y] = x[y] +3; 
            y = y * 2; 
          }
    i always forget how to write tester to array...

    i want somthing like that:

    Java Code:
        public static void main (String[]args)
        {
            a = {2,4,0,1,-6,3,8,7,5};
            b = 3
         }
    The question is: how to write the a array and send a,b to changer...

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    5

    Default Re: Question about tester

    int[] a = { 2, 4, 0, 1, -6, 3, 8, 7, 5 };
    int b = 3;
    changer(a, b);

    ?
    But what do you want to do in the second line of your changer method ? y = y * 2; <--
    That will not change your b !

  3. #3
    bside is offline Member
    Join Date
    Sep 2011
    Posts
    3
    Rep Power
    0

    Default Re: Question about tester

    That's from test question.. and i wish to back to the moment that i thought that b will change..... 15 points for that question :(



    thanks.

  4. #4
    bside is offline Member
    Join Date
    Sep 2011
    Posts
    3
    Rep Power
    0

    Default Re: Question about tester

    BlueJ scream the next error:
    non - static method changer (int[],int) cannot be referenced from a static context.

  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,458
    Rep Power
    25

    Default Re: Question about tester

    The main() method is static. It can only call static methods in the same class unless there is a instance of the class to use.

Similar Threads

  1. Looking for SOFTWARE TESTER
    By global.jobsection in forum Jobs Offered
    Replies: 0
    Last Post: 07-21-2011, 10:48 AM
  2. http://localhost:8080/helloservice/HelloService?Tester HTTP Status 404 -
    By vietnamusa in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 03-13-2011, 12:02 AM
  3. question
    By er_murli4u in forum New To Java
    Replies: 1
    Last Post: 02-20-2011, 06:07 PM
  4. Question concerning question marks and colons
    By jim01 in forum New To Java
    Replies: 17
    Last Post: 01-14-2011, 12:05 AM
  5. Question mark colon operator question
    By orchid in forum Advanced Java
    Replies: 9
    Last Post: 12-19-2010, 08:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •