Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: ParameterMystery problem

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post ParameterMystery problem

    can anyone explain how you get this outs when you run this code.

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

    z = mystery(x, z, y); // Statement 1
    System.out.println(x + " " + y + " " + z); // Statement 2
    x = mystery(z, z, x); // Statement 3
    System.out.println(x + " " + y + " " + z); // Statement 4
    y = mystery(y, y, z); // Statement 5
    System.out.println(x + " " + y + " " + z); // Statement 6
    }

    public static int mystery(int z, int x, int y) {
    z--;
    x = 2 * y + z;
    y = x - 1;
    System.out.println(y + " " + z);
    return x;
    }
    }


    Output
    3 0
    1 2 4
    4 3
    5 2 4
    8 1
    5 9 4


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: ParameterMystery problem

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Please post code correctly.

Similar Threads

  1. Catch block problem. Please fix my problem.
    By damnitsme in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 3rd, 2014, 01:49 AM
  2. Problem with Project Euler problem 18
    By sara_magdy in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 19th, 2013, 12:46 PM
  3. Replies: 3
    Last Post: January 5th, 2012, 01:44 AM
  4. [SOLVED] [Problem] imports javax.swing problem
    By Brollie in forum AWT / Java Swing
    Replies: 8
    Last Post: July 5th, 2009, 07:59 AM
  5. Java program for 2-D Array Maze
    By Peetah05 in forum Collections and Generics
    Replies: 11
    Last Post: May 8th, 2009, 04:30 AM