Results 1 to 4 of 4
  1. #1
    MAJ
    MAJ is offline Member
    Join Date
    Jul 2014
    Posts
    17
    Rep Power
    0

    Default Need help understanding Parameter Mystery

    public class ParameterMystery {
    public class static void main(String[] args)
    {
    int x = 9
    int y = 2;
    int z = 5;

    mystery(z, y,x);
    mystery(y,x,z);

    public static void mystery (int x, int z, int y)
    {
    System.out.println(z + " and " + (y -x);

    }
    }

    How can I figure out what the output would be without using a compiler?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,679
    Blog Entries
    7
    Rep Power
    21

    Default Re: Need help understanding Parameter Mystery

    Note that the names x,y and z of the local variables have nothing to do with the names of the parameters of the other method; it's their values that count, i.e. the values (5, 2 , 9) and (2, 9, 5) are passed to that method; you figure out what that method does given those parameter values; not much of a mystery ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,120
    Rep Power
    20

    Default Re: Need help understanding Parameter Mystery

    Unless this is a one of the OCJP (or whatever the acronym is) question, in which case the answer is "it won't compile".
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,679
    Blog Entries
    7
    Rep Power
    21

    Default Re: Need help understanding Parameter Mystery

    Quote Originally Posted by Tolls View Post
    Unless this is a one of the OCJP (or whatever the acronym is) question, in which case the answer is "it won't compile".
    Oh no, not one of those again ... a forgotten semicolon or superfluous right curly bracket or something misspelled ... I hate those questions.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Cannot find Symbol error - mystery problem
    By Humphrey Bogart in forum New To Java
    Replies: 1
    Last Post: 10-20-2012, 07:57 PM
  2. The Mystery of the auto-morphing variables
    By Luxpsycho in forum Advanced Java
    Replies: 3
    Last Post: 08-11-2011, 01:06 PM
  3. Replies: 2
    Last Post: 03-03-2011, 11:08 PM
  4. Derby Mystery..!!!!
    By yiantzi in forum JDBC
    Replies: 3
    Last Post: 01-24-2011, 12:59 PM

Tags for this Thread

Posting Permissions

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