Results 1 to 3 of 3
  1. #1
    bhavneetkaur is offline Member
    Join Date
    Nov 2012
    Posts
    4
    Rep Power
    0

    Default increment and decrement concept in java

    class fun
    {
    static int f1(int i)
    {
    System.out.print(i + ",");
    return 0;
    }

    public static void main (String[] args)
    {
    int i = 0;
    i= i++ ;
    System.out.print(i);

    int j=0;

    j=j+i;
    System.out.print(j);
    }
    }

    output=00
    i++ is post increment operator then
    why j=0

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default Re: increment and decrement concept in java

    Please use [code] tags [/code] when posting code.
    Java Code:
    i = i++;
    What is the value of 'i' after this line?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    5

    Default Re: increment and decrement concept in java

    the value of i is assigned before the i++ is evaluated, so i is equals 0. I must admit the code is quite tricky!

Similar Threads

  1. Java concept help
    By DMarsh12 in forum New To Java
    Replies: 1
    Last Post: 02-15-2012, 07:06 PM
  2. mailing concept in java
    By sniffer139 in forum Networking
    Replies: 1
    Last Post: 02-22-2010, 10:34 AM
  3. Map concept in JAVA
    By Mathan in forum New To Java
    Replies: 19
    Last Post: 06-27-2008, 06:02 AM
  4. Which concept used in java for monitoring the printer
    By kalinga2k4 in forum Networking
    Replies: 1
    Last Post: 06-14-2008, 01:25 AM
  5. easy way to study the java springs concept
    By kumar84 in forum New To Java
    Replies: 1
    Last Post: 07-17-2007, 03:53 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
  •