Results 1 to 7 of 7
  1. #1
    and0rsk is offline Member
    Join Date
    Oct 2010
    Posts
    6
    Rep Power
    0

    Default Testing arguments

    How would I test in a method with two formal parameters : one a previous defined array of integers and the other an int in which the method returns true if the second argument is contained within the first array argument and returns false otherwise. Honestly, I don't quite understand what i am testing so if you can just give me an idea of what I need to be doing that would help.

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,349
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by and0rsk View Post
    How would I test in a method with two formal parameters : one a previous defined array of integers and the other an int in which the method returns true if the second argument is contained within the first array argument and returns false otherwise. Honestly, I don't quite understand what i am testing so if you can just give me an idea of what I need to be doing that would help.
    Java Code:
    public boolean contains(int[] array, int num) {
       // your code goes here ...
    }
    kind regards,

    Jos

  3. #3
    and0rsk is offline Member
    Join Date
    Oct 2010
    Posts
    6
    Rep Power
    0

    Default

    thanks...quick question also.....i keep on getting a type mismatch error in this method...why? i also get dead code for i++
    public static boolean contains(int[] A, int int1){
    for (int i = 0; int , A.length; i++) {
    if (int1 == A[i])
    return true;
    }
    else {return false;}
    }
    }

  4. #4
    and0rsk is offline Member
    Join Date
    Oct 2010
    Posts
    6
    Rep Power
    0

    Default

    sorry made a small error before in typing code.
    public static boolean contains(int[] A, int int1){
    for (int i = 0; int ,i < A.length; i++) {
    if (int1 == A[i])
    return true;
    }
    else {return false;}
    }
    }

  5. #5
    and0rsk is offline Member
    Join Date
    Oct 2010
    Posts
    6
    Rep Power
    0

    Default

    ignore the extra int put in there please

  6. #6
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,349
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by and0rsk View Post
    ignore the extra int put in there please
    Don't start multiple threads for the same question; show us your final code between [code] ... [/code] tags and show us the compiler diagnostic messages verbatim.

    kind regards,

    Jos

  7. #7
    Ronin is offline Senior Member
    Join Date
    Oct 2010
    Posts
    317
    Rep Power
    4

Similar Threads

  1. Replies: 8
    Last Post: 09-23-2010, 12:07 AM
  2. JUnit testing
    By hedonist in forum Advanced Java
    Replies: 4
    Last Post: 10-04-2009, 12:06 PM
  3. XML to JSP Unit Testing
    By Abder-Rahman in forum Advanced Java
    Replies: 2
    Last Post: 02-15-2009, 12:35 AM
  4. Testing JUnit PDE with Ant
    By keynan in forum Eclipse
    Replies: 0
    Last Post: 02-14-2008, 11:35 PM

Posting Permissions

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