It is Very simple but intresting...........plz give me ans of my simple pro

<h4>
Hi friends ,
I have some probs. that i can not understood the
logic behind this......if any one know plz reply me.
This is one sample prog.
class test
     public static void main(String str[])
          int i=10;
          int j=i++;
          System.out.println(j + " " + i);
output : i=11 and j=10
=================================================================
now if i change this prog.
class test
     public static void main(String str[])
          int i=10;
          i=i++;
          System.out.println(i);
now it display value of i is : 10
why ? the rule of post increment is that first
assign the value and then increment the value of the
variable. But when i m using same var. as left side
it will not increment.
Can any one help me why is it?
plz reply me if u know...
Thank You in Advance.
</h4>

ThomHehl wrote:
I'm just kinda spitballing here, but you have to think about the way this gets translated into machine code.
When you do an assignment, it moves a value from one memory location to another. When it sees both assignments and that there are further operations to do on the sending part, in order to prevent the value from getting "stepped on" it first creates a new memory location to store the value, then continues processing what is still in the register. In this case, it increments i after the new location has been created.
This is how it would operate if precedence is to work properly and you had further operations that were lower priority than assignment. Make sense?No.
Whenever we have LHS = RHS; RHS is evaulated completely and the value of the RHS expression is then stored in the LHS variable. In the case of i = i++; we first evaluate the i++, which has the side effect of incrementing i. Then the value of the expression i++ is stored in the LHS--in i.
Since the value of i++ is i's original value (Remember, the post-increment operator increments the variable after getting its current value), that's what's stored in the LHS as a result of the assignment.
int i = 1;
i = i++;
// is equivalent to
int i = 1;
tmp = i; // get original value of i as the value of the expression i++, tmp = 1
i = i + 1; // increment i, i = 2
i = tmp; // this is the "i = " part

Similar Messages

  • Plz give the ans

    1)why we used tiff file in  scripts?
    2) if we have a quality client 300 in this client is it works scripts?
    3) what is difference 4.6 c and 4.7 EE version?
    4) give me some idea about ecc 6.0  version?
    5) what is the purpose of code inspector?
    6) in LSMW  why we prefer session method?why we used direct method some times only?
    7) how to debugs smart forms?
    8) difference  between split and concatenate?
    9) in which situation  we can create secondary index?
    10) what r the different type of session?
    11)how to handle the error in call traction with step loop?
    12)what is conversion routine why we used?
    13) can we generated 2 session in BDC ? how?

    8)difference between split and concatenate?
    Split  will split a string  into different portion  , splitting at a particular charactor.
    lets  a = 'a b c d'
    split a   at ' '  into  b c d e.
    then b ='a'
    c = 'b'
    d = 'c'
    e = 'd'
    But concatinate will combaine different pieces of string into one sstring
    CONCATENATE b c d e INTO  a.
    then a = 'abcd'
    11)how to handle the error in call traction with step loop?
    data : bdcmsg like bdcmsgcoll occurs 0 with header line.
    call transaction 'SE11' using it_bdc mode 'N' update 'A' messages into bdcmsg.
    loop at bdcmsg.
    call function 'FORMAT_MESSAGE'
    exporting
       id              = sy-msgid
       lang            = '-D'
       no              = bdcmsg-msgnr
       v1              = bdcmsg-msgv1
       v2              = bdcmsg-msgv2
       v3              = bdcmsg-msgv3
       v4              = bdcmsg-msgv4
    importing
       msg             = bdcmsg-msgv1
    exceptions
       not_found       = 1
       others          = 2
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    if bdcmsg-msgnr = 428 .
    success = success + 1.
    endif.
    write: /  bdcmsg-msgv1.
    endloop.
    Here bdcmsgcoll  is a  message handaling structure  .
    13) can we generated 2 session in BDC ? how?
    *& Report  ZBDCZMASTERSESSION
    report  zbdczmastersession.
    tables: plsc.
    types: begin of s1,
           empid type zmaster-empid,
           name type zmaster-name,
           age type zmaster-age,
           end of s1.
    data : it_tab type s1 occurs 0 with header line.
    data : it_bdc type bdcdata occurs 0 with header line.
    data : session like apqi-groupid value 'Sar'.
    select * from zmaster into table it_tab.
    call function 'BDC_OPEN_GROUP'
    exporting
    client          = sy-mandt
    group          = session
    user          = sy-uname
    exceptions
       client_invalid            = 1
       destination_invalid       = 2
       group_invalid             = 3
       group_is_locked           = 4
       holddate_invalid          = 5
       internal_error            = 6
       queue_error               = 7
       running                   = 8
       system_lock_error         = 9
       user_invalid              = 10
       others                    = 11
    if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
             with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    refresh it_bdc.
    loop at it_tab.
    *IF SY-TABIX < 2.
    refresh it_bdc.
    perform bdc_dynpro      using 'SAPMSRD0' '0102'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RSRD1-TBMA_VAL'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=SHOW'.
    perform bdc_field       using 'RSRD1-TBMA'
                                  'X'.
    perform bdc_field       using 'RSRD1-TBMA_VAL'
                                  'ZMASTER'.
    perform bdc_dynpro      using 'SAPLSD41' '2200'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=TDED'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'DD03P-FIELDNAME(01)'.
    perform bdc_dynpro      using '/1BCDWB/DBZMASTER' '0101'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'ZMASTER-AGE'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=SAVE'.
    perform bdc_field       using 'ZMASTER-EMPID'
                                  it_tab-empid.
    perform bdc_field       using 'ZMASTER-NAME'
                                  it_tab-name.
    perform bdc_field       using 'ZMASTER-AGE'
                                  it_tab-age.
    perform bdc_dynpro      using '/1BCDWB/DBZMASTER' '0101'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/EBACK'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'ZMASTER-EMPID'.
    perform bdc_dynpro      using 'SAPLSD41' '2200'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=WB_BACK'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'DD03P-FIELDNAME(01)'.
    perform bdc_dynpro      using 'SAPMSRD0' '0102'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RSRD1-TBMA_VAL'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=BACK'.
    perform bdc_field       using 'RSRD1-TBMA'
                                  'X'.
    perform bdc_field       using 'RSRD1-TBMA_VAL'
                                  'ZMASTER'.
    *call transaction 'SE11' using it_bdc mode 'A' UPDATE 'A' MESSAGES INTO BDCMSG.
    *CALL FUNCTION 'BDC_INSERT'
    EXPORTING
      TCODE                  = 'SE11'
    *TABLES
    *DYNPROTAB     = IT_BDC
    EXCEPTIONS
      INTERNAL_ERROR         = 1
      NOT_OPEN               = 2
      QUEUE_ERROR            = 3
      TCODE_INVALID          = 4
      PRINTING_INVALID       = 5
      POSTING_INVALID        = 6
      OTHERS                 = 7
    *IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *ENDIF.
    *WRITE:/ ' CREATED '.
    *ENDIF.
    endloop.
    call function 'BDC_CLOSE_GROUP'
    exceptions
       not_open          = 1
       queue_error       = 2
       others            = 3
    if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
             with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    *call transaction 'SM35'.
    *SUBMIT RSBDCSUB.
    *SUBMIT RSBDCreo.
    submit rsbdclog.
           Start new screen                                              *
    form bdc_dynpro using program dynpro.
      clear it_bdc.
      it_bdc-program  = program.
      it_bdc-dynpro   = dynpro.
      it_bdc-dynbegin = 'X'.
      append it_bdc.
    endform.
           Insert field                                                  *
    form bdc_field using fnam fval.
      if fval <> ''.
        clear it_bdc.
        it_bdc-fnam = fnam.
        it_bdc-fval = fval.
        append it_bdc.
      endif.
    endform.
    'BDC_OPEN_GROUP' will create sessions

  • I have iphone 5S after update of 8.0 and 8.0.2 t consume battery very much( only 3 hrs backup). Plz give some solution.Now i am going frustrated from Apple

    I have iphone 5S after update of 8.0 and 8.0.2 t consume battery very much( only 3 hrs backup). Plz give some solution.Now i am going frustrated from Apple

    I'm not sure, but I know it's not recommended to upgrade to iOS 8 on anything older than an iPhone 5. I only lost my music playlists and music that was on my phone, but that music is also on my iTunes, not the playlists though, and I don't want to go through ALL my iTunes library to fix it either... But it seems I don't have a choice right now.
    Whatever you do, do NOT upgrade to iCloud Drive, keep iCloud till OS X Yosemite comes out, if your computer is a Mac. I also just noticed that all my documents on my phone are gone from Pages, BUT if I go on the iCloud website they are still there. Hopefully it will all work itself out when I can update my macbook pro to OS X Yosemite.
    If you backed up your phone and all your purchases off your iPhone prior to trying to upgrade you should be fine... But I'm not even remotely sure.

  • Hello Apple, Plz give us the classic look option like iOS 6. We miss that appearance which shew all icons as a gems but now in ios 7 all icons look like a cheap stickers and worst than android look. Plz think about it, heartily request to You dear Apple.

    Hello Apple, Plz give us the classic look option like iOS 6. We miss that appearance which shew all icons as a gems but now in ios 7 all icons look like a cheap stickers and worst than android look. Plz think about it, heartily request to You dear Apple.

    There is no Apple in this forum this is a user to user forum.
    send your feedback here http://www.apple.com/feedback/

  • I have iPhone 4 and I have purchased this from Dubai and now I am in India but now my phone didnot working here .so plz give me solution for this so I will use this in India.can I factory unlocked my iPhone by apple store at jaipur india

    I have iPhone 4 and I have purchased this from Dubai and now I am in India but now my phone didnot working here .so plz give me solution for this so I will use this in India.can I factory unlocked my iPhone by apple store at jaipur india

    ONLY the carrier it is locked to can authorize unlocking it. Most have restrictions in that you must be a current customer and have maintained service for a minimum period of time. Do yourself a favor, sell it and purchase a phone in India instead.

  • I buy my ipod touch like 6 months ago it was working very well but yesterday it is not connecting to the internet when i am connect to my internet it said unable to connect can you please tell me plz help me

    i buy my ipod touch like 6 months ago it was working very well but yesterday it is not connecting to the internet when i am connect to my internet it said unable to connect can you please tell me plz help me

    Do other devices successfully connect to the router?
    Does the iPod successfully connect to other networks/routers?
    Does the iPod show wifi bands in the upper left?
    Try:
    - Resetting the iPod:
    Reset iPod touch:  Press and hold the On/Off Sleep/Wake button and the Home
    button at the same time for at least ten seconds, until the Apple logo appears.
    - Powering off and then back on the router
    - Resetting networksettings: Settings>General>Reset>Reet Network Setting
    - The troubleshooting here
    iPhone and iPod touch: Troubleshooting Wi-Fi networks and connections

  • TS2326 my ios is 5.1.1 but still im facing to this issue, this is very annoying... plz help me

    my ios is 5.1.1 but still im facing to this issue, this is very annoying... plz help me

    You need to tell us what "this issue" is if you want help.

  • Can anybody plz give me Smartforms print prog for Invoice/PackList

    Hello Smartforms Gurus
      Can anybody plz give me Smartforms print prog for Invoice/Packing List. I need to develop the same from scratch. I know Smartform for simple Application but   complex application i need to refer u all guys prog plz.
    I would be greatful plz.          
    Thnx In Advance

    Hi,
    Could you please give me the link where you found these  group of pre-configured smartforms available in sap labs?
    I looked for... but i have not founded it.
    Thanks in advance!.
    Regards,
    Albio.-

  • I own a 13-inch MacBook Pro and for the past day, my wifi on my laptop says I only have two bars of connection and is running very slow,but all of my other devices such as my iPhone and iPad are connecting perfectly to the wifi. How can I fix this? Thanks

    I own a 13-inch MacBook Pro and for the past day, my wifi on my laptop says I only have two bars of connection and is running very slow,but all of my other devices such as my iPhone and iPad are connecting perfectly to the wifi. How can I fix this? I have tried to shut my laptop off and let it rest and I have also re-started my wifi router three different times. Someone please help me with this problem so I can begin to use my laptop again as I take it to school and use it for class.
    Thanks so much!

    FCP, and all software on OSX, has a few different "preference" files (the extension is .plist), which store all your user settings. Each time you resize a window, change a setting, anything, this file is re-written. Kinda easy to see how they would become corrupt every now and then.
    -Close FCP
    -Navigate to User>Library>Preferences and delete com.apple.FinalCutPro.plist
    -Navigate to User>Library>Preferences>Final Cut Pro User Data and delete Final Cut Pro 5.0 Prefs
    -Empty your trash
    Relaunch FCP and see if that worked.
    Download FCP Rescue to make this process easier in the future. When you have FCP running really smooth, open FCP Rescue and create a backup of your preference files. If it starts acting wanky, just run FCP Rescue and Restore your backup preferences. Works really slick, and it's free.
    EDIT: Or use the really simple explaination that X posted as I was typing.

  • Simple but reliable small office setup

    Hi group,
    I need some advice on setting up a simple but reliable small office wireless network. Up until now, we had a consumer AP combined with wired connections. However, we're moving to a new office where it's difficult to implement a wired network and we decided to implement a good quality wireless network.
    So, I was looking into business quality wireless AP's and it looks as if the Aironet 1600 is an interesting option. However, I'm not a (wireless) network specialist and have no knowledge of controlled AP's.
    The office is (only) 278 square meters (24 x 11.6), divided in two main areas by a supporting wall with two large doorways. I would like to keep the setup costs to a minimum, ideally using only 1 AP. This might mean placing the AP on the ceiling near the dividing wall (which is roughly in the middle), or on the wall itself.
    We need to support fast wireless connections from 15 laptop computers now, and up to 25 in the near future. Also, we'd like to support 15-25 mobile devices, i.e. tablets or smart phones.
    I've found some info on the differences between the AIR-CAP1602 and AIR-SAP1602 models, as well as the Internal and External antenna versions. It seems to me we could use the Standalone (SAP1602) model. However, I don't have enough knowledge to determine if the Aironet 1600 is actually appropriate for our requirements and if yes, which model.
    I would very much appreciate your advice!

    A 1600 would work or even a 2600. I prefer the 2600/3600 though but cost is your concern. I would also place the AP on the ceiling but belies the ceiling maybe in the middle if possible. Don't place the AP above the ceiling because you will loose coverage. Internal antennas are fine and just to note, rule of thumb is 25 users per AP so just in case you need more throughput, maybe using two separated by 3-5 meters would help also. If the 1600's are the choice for you then look at having one or two APs.
    Sent from Cisco Technical Support iPhone App

  • Hey guyz my ipod touch 4g is not green battery symbol while charging or syncing on home screen nor it get charge?? plz give me some suggestion

    hey guyz my ipod touch 4g is not green battery symbol while charging or syncing on home screen nor it get charge?? plz give me some suggestion

    no buddy,  when my i pod touch 4 is off  i press its power button then it display a black screen in which there is an empty battery with red marking in side   an,,
    when i connect it with usb cable which i got with i pod touch....then itlike this in picture.. but after some time it get start to home screen with 20 % battery ..and no charging take place and no syncing take ....nor i tunes find it

  • Graphic card problem maybe? Since when I have changed the hard drive to my macbook pro and I installed all the new softwares, my mac is very slow and the screen gives crazy pictures,could maybe be the graphic card, does anybody have experienced this?

    Graphic card problem maybe? Since when I have changed the hard drive to my macbook pro and I installed all the new softwares, my mac is very slow and the screen gives crazy pictures,could maybe be the graphic card, does anybody have experienced this?

    after a restart it works for a time, but always slow. I went to the Applestore this afternoon and the made a check and said it would be the logicboard and they would have to change it for CHF 600 and it would be ready in 10 - 15 days

  • I having apple 8 GB ipod , i need saving my pictures ipod to my computer, plz give me the method.............!

    i having apple 8 GB ipod nano , i need saving my pictures ipod to my computer, plz give me the method or solution............!

    You'll likely need the assistance of some third party software such as the one below to get the job done.  Keep in mind that your photos will no longer be in their full resolution, but instead will be the scaled down thumbnail versions that were optimized for viewing on your iPod.
    http://www.macroplant.com/phonetopc/
    Google "copy photos from iPod" for more possible software solutions.
    B-rock

  • Hello dear repersented. i have a iphone 3g seriel no.85945sy43nr using at saudi arbia bcz this phone is coming from Uk thats y the sim is not working at here . so plz give me sulution of this problum.

    hello dear repersented. i have a iphone 3g seriel no.85945sy43nr using at saudi arbia bcz this phone is coming from Uk thats y the sim is not working at here . so plz give me sulution of this problum.

    um..pretty simple solution. when you bought this iphone its obviously still linked to the old sim which is probably a UK carrier. you need to contact whoever you bought it from and get them to pay the fee to use this phone on a saudi arabian sim.

  • Extremely simple but baffling to me: Constructors.

    I haven't a clue what they are. I've read about them online and in the Java API, and I still have no idea what they are.
    My current understanding is this: a constructor is code dedicated towards defining how to treat a variable.
    But...I have to write two programs using constructors and I have no idea what to put in them. And in fact everything I've tried gives compiler errors. I'm sure all of you know the quiet desperation and frustration I'm feeling.
    Anyway, the assignments are:
    1) Create a class called Employee that includes three pieces of information as instance variables - a first name (type String), a last name (type String) and a monthly salary (double). Your class should have a constructor that initializes the three instance variables. Provide a set and a get method for each instance variable. If the monthly salary is not positive, set it to 0.0.
    Write a test application named EmployeeTest that demonstrates class Employee's capabilities. Create two Employee objects and display each object's yearly salary. Then give each Employee a 10% raise and display each Employee's yearly salary again.
    2) Create a class called Date that includes three pieces of information as instance variables - a month (type int), a day (type int), and a year (type int). Your class should have a constructor that initializes the three instance variables and assumes that the values provided are correct. Provide a set and a get method for each instance variable. Provide a method displayDate that displays the month, day, and year separated by forward slashes.
    Write a test application named DateTest that demonstrates class Date's capabilities.
    It all seems extremely vague, to me.
    For the first assignment I've got:
    public class Employee
         public String FirstName;
         public String LastName;
         public double Salary;
    Which I think is right. But all attempts to create a constructor that have failed...I don't even know what one does. It seems kind of absurd for my first two labs to be so simple, basically logic exercises, and this to be so mind-destroying.
    There's got to be an if/then to see if the salary inputted is negative, which is simple, no problem.
    But the set and get methods...there's no data inputted into this program, so what the hell is it setting and getting, and how would the syntax work?
    Like:
    public void setFirstName( String FirstName )
    FirstName = FirstName;
    Doesn't work. And I think it's because it refers to itself for its own definition, which is nonsense. But I can't figure out what's right.
    The second assignment is simpler, but it also makes no sense to me. The day, month, and year are not variables. And even if they are variables, the user doesn't input them only to have them displayed, right? So what is the assignment even asking for? This is all taken directly out of the book.
    Any help is appreciated. =/

    FuneralParlor wrote:
    I haven't a clue what they are. I've read about them online and in the Java API, and I still have no idea what they are.That's not a good sign.
    My current understanding is this: a constructor is code dedicated towards defining how to treat a variable.No. They initialize an object.
    When you buy a new XBox, you have to spend some time taking it out of the box, removing the packaging, and plugging the wires together. It's like that.
    But...I have to write two programs using constructors and I have no idea what to put in them. You don't necessarily need to put anything in them. Does your class require initialization on the objects created for it?
    And in fact everything I've tried gives compiler errors. I'm sure all of you know the quiet desperation and frustration I'm feeling.It sounds like you're trying random stuff, hoping something will work. Don't do that.
    Anyway, the assignments are:...
    >
    It all seems extremely vague, to me.It doesn't give you the answers, but it tells you how to do them. It's pretty specific.
    For the first assignment I've got:
    public class Employee
         public String FirstName;
         public String LastName;
         public double Salary;
    Which I think is right.Well, generally fields shouldn't be public; they should be private. Also, you're not following Java naming conventions. Fields should start with a lower-case letter ("firstName" not "FirstName").
    But all attempts to create a constructor that have failed...I don't even know what one does. It seems kind of absurd for my first two labs to be so simple, basically logic exercises, and this to be so mind-destroying.It's simple stuff. I find it hard to believe that you've read your textbook.
    I'll give you a hint. The assignment says:
    Your class should have a constructor that initializes the three instance variables. This means that the constructor will need to take arguments, so you can use the arguments's values to assign to the fields (instance variables).
    But the set and get methods...there's no data inputted into this program, so what the hell is it setting and getting,The assignment tells you exactly what's going to be invoking the setter and getter methods:
    Write a test application named EmployeeTest that demonstrates class Employee's capabilities. [etc]
    and how would the syntax work?
    Like:
    public void setFirstName( String FirstName )
    FirstName = FirstName;
    Doesn't work. And I think it's because it refers to itself for its own definition, which is nonsense. But I can't figure out what's right.Right. In this case, the parameter name is obscuring the field name. This is where the "this" keyword comes in handy:
    this.Firstname = Firstname;Your textbook and teacher should have mentioned this.
    The second assignment is simpler, but it also makes no sense to me. The day, month, and year are not variables. What do you mean they're not variables? The assignment clearly says to make them so.
    And even if they are variables, the user doesn't input them only to have them displayed, right? So what is the assignment even asking for? It's just a super-simplified example. You're right; it's worthless in terms of real-world practicality. It's just something pointless but simple for you to get practice with. Don't worry about it.

Maybe you are looking for