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 3 of 3

Thread: hi if u can help me please to figure this how D become result of 1

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

    Default hi if u can help me please to figure this how D become result of 1

    int a = 1;
    int b = 2;
    int c;
    int d;
    c = ++b;//3
    d = a++;//2
    c++;//4
    System.out.println("a = " + a);
    System.out.println("b = " + b);
    System.out.println("c = " + c);
    System.out.println("d = " + d);


  2. #2
    Member
    Join Date
    Sep 2012
    Posts
    128
    Thanks
    1
    Thanked 14 Times in 14 Posts

    Default Re: hi if u can help me please to figure this how D become result of 1

    The answer is correct. It has to do with when the increment/decrement occurs. For a fuller explanation, please check the relevant chapter in the text you are using to learn Java or online.

    Assignment, Arithmetic, and Unary Operators (The Java™ Tutorials > Learning the Java Language > Language Basics)

  3. #3
    Junior Member
    Join Date
    Apr 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: hi if u can help me please to figure this how D become result of 1

    thanks

Similar Threads

  1. Isn't the result supposed to be 6?
    By obel1x in forum Java Theory & Questions
    Replies: 3
    Last Post: April 12th, 2014, 03:43 AM
  2. [SOLVED] Got different result from (Eclipse VS NetBean)
    By SmokyBrain in forum Java IDEs
    Replies: 4
    Last Post: May 4th, 2012, 07:08 AM
  3. Implementing Sha256 and not getting the result I should get
    By ydan87 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: December 26th, 2011, 03:30 PM
  4. Result set is closed
    By keshav_agrawal89 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: June 11th, 2011, 08:35 AM