Predecrement and Post-decrement,,need help!!!!!!

Hi everyone,
I tried to compile the following code on my pc, and it produced different results as I expected, can anyone explain to me why? thanks
public static void main (String[] args)
   int a=5,b=5,c=5,d=5;
   System.out.println( a-- + a); //line one
   System.out.println( b + b--); //line two
   System.out.println( --c + c);  //line three
   System.out.println(d + --d);  //line four
}where I think line one should produce the output 10, but I got the result 9 instead. Is it that "a--" was supposed to be evaluated after the "a+a"????
Line two produces 10, and I am satisfied with the result, because b-- was evaluated after "b+b" .
At line three, it's getting more confused, --c+c produces 8 !!!!!* , can anyone tell me why??????
Line four produces 9, why???
I also have a few more questions regarding this issue:
*if  d=4
how would expression
d-- + --d   //exp 1
--d + d--   //exp 2
d-- + d--   //exp 3
--d + --d    //exp 4be evaluated????????*
plz anybody can explain this to me, thanks!!!!
Edited by: df2334 on Jan 2, 2008 4:11 PM
Edited by: df2334 on Jan 2, 2008 4:18 PM

df2334 wrote:
Hi everyone,
I tried to compile the following code on my pc, and it produced different results as I expected, can anyone explain to me why? thanks
public static void main (String[] args)
int a=5,b=5,c=5,d=5;
System.out.println( a-- + a); //line one
System.out.println( b + b--); //line two
System.out.println( --c + c);  //line three
System.out.println(d + --d);  //line four
// 1
a is 5, so the value of the expression "a--" is 5 a is then decremented to 4. So it's 5 + 4.
// 2
b is 5. The value of the expression "b--" is 5. So it's 5 + 5. b is then decremented to 4.
// 3
c is 5. c is decremented to 4 and the value of expression "--c" is 4. So it's 4 + 4.
// 4
d is 5. d is then decremented to 4. The value of expression "--d" is 4. So it's 5 + 4.
And the lesson we learn is: Don't use the variable you're ++ing or ing in the same statement you're ++/ing it in other than the ++/-- expression.

Similar Messages

  • Default key date, Document date and posting date needs to be changed automa

    Hi Experts,
    The user wants to create a variant for Foreign currency valuation, wherein the default key date, Doc date and Posting date needs to be changed every month automatically. Is it possible?
    Please let me know your thoughts.
    Warm regards,
    Murukan Arunachalam

    Hi
    Please follow this process.
    Only specify fields that should be changed
    Select these fields by entering an X in the checkboxes
    Enter a U in the UPDATEFLAG field
    Always specify key fields when changing the data, including in the checkboxes
    The configuration is an exception here. If this needs to be changed, you need to complete it again fully.
    Maintain quantities and dates in the schedule line data.
    1. Minimum entry:
    You must enter the order number in the SALESDOCUMENT structure.
    You must always enter key fields for changes.
    You must always specify the update indicator in the ORDER_HEADER_INX.
    2. Commit control:
    The BAPI does not run a database Commit, which means that the application must trigger the Commit so that the changes are read to the database. To do this, use the BAPI_TRANSACTION_COMMIT BAPI.

  • I have printers at home and work. i need help programing my macbook print utility so computer knows which printer to use depending on where i am. thanks

    i have printers at home and work. i need help programing my macbook print utility so computer knows which printer to use depending on where i am. thanks

    Look for cloud solutions such as DropBox, OneDrive, SugarSync or others. They are all cloud based services that sync documents between computers via the cloud. Of course another solution is simply a flash drive formatted in exFat so that Macs and Windows computers can read it.

  • Wish I didn't upgrade! and now I need help to figure out how to make it wor

    I have a Windows XP Pro 2nd edition with IE ver 6.0.2 (but I normally use FireFox)
    I've never had any trouble with iTunes until iTunes "forced" me to upgrade my iTunes applicaiton to version 6 if I wanted to "purchase" music. (note to self: Purchase music from stores it's much safer)...
    I upgraded and received no error messages. Trouble is now, when I launch the iTunes application it doesn't "open" ... although the iTunes process begins to run in the background process (ctraltdelete).
    I have uninstalled and installed 5 different times and ways.
    First uninstall was "typical" uninstall. THat didn't fix it.
    Second uninstall was "typical" unistall from the Control Panel, and then I removed the folders from the "program File" folder. Still wouldn't work.
    Third unintall was "typical" then I removed folders from local drive and removed all "known" registry "itune" keys. That didn't work.
    Fourth uninstall was first a "repair" to itunes, and then a "typical" uninstall, then I removed folders, removed registry (does anyone know all of itunes registry keys? Maybe I am missing a few.. the only ones I know of is the "itune" reg). Then I looked through my start up menu from "msconfig" and took a look at my firewall program to see if there was anything preventing the program from running...
    Fifth uninstall pretty much fruitless as my previous attempts.
    I know it HAS to be a registry key of some sort.. here's why:
    When I uninstall and reinstall (no matter how thourough) every time I install the iTunes program Windows XP has never ONCE recognized the new install of iTunes as a "NEW PROGRAM" and it should!
    I need help... what registry keys should I be removing? ANyone suggest for me to remove Quick Time too? What about the ipod updater software? Any connection?
    HELP??????????????????
    THanks
    W.

    hi wmchisholm!
    Trouble is now, when I launch the iTunes application it doesn't "open" ... although the iTunes process begins to run in the background process (ctraltdelete).
    hmmm. is itunes.exe persisting in Task Manager? if so, first check up on these two possibilities:
    iTunes 6 won't open on a Windows computer if firewall software is not up-to-date
    iTunes for Windows doesn't open after upgrading
    but if itunes.exe is disappearing after a few seconds, try the following technique:
    Using MSCONFIG to troubleshoot conflicts in Windows
    ... and let us know the names (exact spelling please) of the start-up items that you had to disable in order to get itunes to launch. (there's a nasty piece of malware out there that has been causing "error-less" itunes launch failures since late October.)
    love, b

  • I recently sold my iphone 4s back to at&t and bought a galaxy s5 but my brother still has an iphone and when he sends me a text it dosnt always go through and i really need help on what to do next please

    I recently sold my iphone 4s back to att and they whiped it clean and now i have a galaxy s5 and my brother still has the iphone but when he sends me texts they dont always go through and i need help on what to do next

    See if this helps:
    iMesssage to old phone
    If you move to another phone and forget to turn off iMessage then read “if you no longer have the device inhttp://support.apple.com/kb/HT5661  If you still cannot resolve it call Apple http://support.apple.com/kb/HE57
    To deactivate iMessage http://support.apple.com/kb/ts5185
    Read http://m.samsung.com/us/support/SupportOwnersFAQPopup.do?faq_id=FAQ00053450&fm_s eq=62995

  • So i have Two account on my imac OS X Lion 10.7.5 and dont have administrator and its locked need help asp please Someone!

    I have a Imac and i cant acces adminastrator Becuase my two users dont have becuase i took them i dident know that would happen and need help i dont wanna loose all the stuff in the imac so if you can help please message me asp

    Use the directions given here:
    http://osxdaily.com/2011/08/24/reset-mac-os-x-10-7-lion-password/

  • No ACL deny logs for Traffic not matched by Static Object NATs and ACL. Need Help.

    I start noticing that I do not see any denied traffic coming in on my ACL.  To better explain, lets say I have this config.
    ### Sample Config ###
    object network webserver
    host 192.168.1.50
    nat (dmz, outside) static X.X.X.X service tcp www www
    access-list inbound extended permit ip any4 object webserver eq www
    If I generate a traffic from the outside let's say a traffic that is trying to access X.X.X.X via TCP Port 8080 which obviously does not have any NAT entry to it going to my DMZ, I don't see the ACL denies it anymore but instead comes back with a Drop Reason: (nat-no-xlate-to-pat-pool) . On the packet trace I got this. (Below) it seems that does not even hit the ACL as there is no xlate found for it, at least to what the drop reason says.
    Phase: 1
    Type: CAPTURE
    Subtype:
    Result: ALLOW
    Config:
    Additional Information:
    MAC Access list
    Phase: 2
    Type: ACCESS-LIST
    Subtype:
    Result: ALLOW
    Config:
    Implicit Rule
    Additional Information:
    MAC Access list
    Phase: 3
    Type: ROUTE-LOOKUP
    Subtype: input
    Result: ALLOW
    Config:
    Additional Information:
    in   0.0.0.0         0.0.0.0         Outside
    Result:
    input-interface: Outside
    input-status: up
    input-line-status: up
    output-interface: Outside
    output-status: up
    output-line-status: up
    Action: drop
    Drop-reason: (nat-no-xlate-to-pat-pool) Connection to PAT address without pre-existing xlate
    Before, using a regular Static PAT on ASA Versions 8.2(5) below, I could get the deny logs (ASA-4-106023). Generally, I use these logs, and are quite important for us specially during auditing.
    My question is how can I generate logs for these type of dropped traffic on the ASA 9.1 Version? 
    Any comments/suggestions are gladly appreciated :)
    Regards,
    John

    I believe, but am not 100% sure, that the reason you are not seeing the ACL drop but a no NAT matched is because of the changes from 8.2 to 8.3 in the order of how things are done.  In 8.3 and later you need to secify the real IP address when allowing packets in, and this is because NAT happens before the ACL is matched.  So since there is no match on the NAT the packet is dropped then and there, never reaching the stage where ACLs are checked.
    As to seeing drops in the ACL log...You might want to try adding an ACL that matches the NATed IP...but I don't think you will have much success with that either.  My guess is that there is no way around this...at least no way I know of.
    Please remember to select a correct answer and rate helpful posts

  • Few errror/doubts in Primary and Standby server - Need Help

    Hi All,
    I am having below doubts/errors. I need help to solve all the below questions.
    I configured Dataguard successfully. Now the sync is upto date using the below parameters (using 11g):
    at primary:
    log_archive_dest_1=
    log_archive_dest_2='SERVICE=standby.123 arch'
    standby_file_management=auto
    at sandby:
    log_archive_dest_1=
    standby_file_management=auto
    Still i face below messages in the alertliog. Can anybody clearly explain me all the points.
    Primary:
    ORA-1652: unable to extend temp segment by 640 in tablespace NEWTEMP
    I get this error when my archvie destination got filled up, later we released the enough space, the archived are generating. Still i see this message once in between. Need to solve this.
    Primary:
    Checkpoint not complete ( i see this message very often, want to get rid of this)
    standby:
    kcrrvslf: active RFS archival for log thread 1 sequence (sometimes i see this KCRRVSLF)
    standby:
    check that the CONTROL_FILE_RECORD_KEEP_TIME initialization parameter is defined to a value that is sufficiently large enough to maintain afequate log switch information to resolve archivelog gaps. (also get this message in between the alertlog file in standby)
    Standby:
    FAL[client]: Error fetching gap sequence, no FAL server specified (this is very often message. How to remove this, what needs to be added. Do i need to add the below parameters)
    FAL_CLIENT
    FAL_SERVER
    Thanks in advance.
    Pas Moh
    [email protected]

    Pas Moh wrote:
    Hi All,
    I am having below doubts/errors. I need help to solve all the below questions.
    I configured Dataguard successfully. Now the sync is upto date using the below parameters (using 11g):
    at primary:
    log_archive_dest_1=
    log_archive_dest_2='SERVICE=standby.123 arch'
    standby_file_management=auto
    at sandby:
    log_archive_dest_1=
    standby_file_management=auto
    Still i face below messages in the alertliog. Can anybody clearly explain me all the points.
    Primary:
    ORA-1652: unable to extend temp segment by 640 in tablespace NEWTEMP
    I get this error when my archvie destination got filled up, later we released the enough space, the archived are generating. Still i see this message once in between. Need to solve this.This error has absolutely nothing to do with the handling of archive logs, the status of archivelog destination, or primary/standby. Any relation you thought you saw was pure coincidence.
    >
    >
    Primary:
    Checkpoint not complete ( i see this message very often, want to get rid of this)
    Here is the very first hit I got when I googled "oracle checkpoint not complete". Tom says it better than I would have.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:69012348056
    standby:
    kcrrvslf: active RFS archival for log thread 1 sequence (sometimes i see this KCRRVSLF)
    A quick google of that one, and it looks like it is not even an error, but rather simply an informative
    >
    standby:
    check that the CONTROL_FILE_RECORD_KEEP_TIME initialization parameter is defined to a value that is sufficiently large enough to maintain afequate log switch information to resolve archivelog gaps. (also get this message in between the alertlog file in standby)
    In that case I would check that the CONTROL_FILE_RECORD_KEEP_TIME initialization parameter is defined to a value that is sufficiently large enough to maintain adequate log switch information to resolve archivelog gaps.
    How big is that? Well, at least bigger than it is now. Beyond that, it would have to be "large enough to maintain adequate log switch information to resolve archivelog gaps" Just play with it until you get the result you want.
    >
    Standby:
    FAL[client]: Error fetching gap sequence, no FAL server specified (this is very often message. How to remove this, what needs to be added. Do i need to add the below parameters)
    FAL_CLIENT
    FAL_SERVER
    Thanks in advance.
    Pas Moh
    [email protected]

  • I have EMS 3.5 installed and functioning. Need help with where to go next!

    Hello All,
    I am brand new to this and need a very basic push in the right direction.
    I have FMS 3.5 installed on my server and I am ready to begin testing with it.
    My website has a page with descriptions of videos and links to those videos.
    When a link is selected, I want a new page to open and the video to play in the FMS player.
    I have absolutely no idea how to go about this. I need some meaty information here. I read tom Green's tutorials, and although I found that they were informative, they are also quite general.
    I have Flash Professional CS4 and I just need to know what the heck to do next.
    Any and all help will be supremely appreciated.
    Sincerely,
    wordman

    Gentlemen,
    Thank you for the answers, I will definitely look into what you both suggested.
    My next step is getting a player into a separate page that plays selected videos through RTMP.
    The player that comes with FMS would be fine, but I do not know how to alter it, change colors, etc.
    Then I was looking into Real Eyes' REOPS player, and the white papers alone stopped me in my tracks. I realize it's probably easy, but now ehrn you are a novice, to understand it.
    Then I saw Adobe Strobe, the OSMF-based player and thought that might be good for me.
    The biggest problem I see is that Adobe's resources are not always easy to find on this website, same goes fo rthe OSMF site. Not very well structured sites for a software company.
    Bottom line is, I need to get a player on a page that plays though RTMP. Any thoughts there? I'm completely new to Flash.
    Thank you all!!!
    Sincerely,
    wordman

  • On my MacBook Pro I forgot my user password and I didn't enable Apple ID recoveries and I urgently need help finding a way to recover the password.

    I urgently require help in recovering my user password for my MacBook Pro on OS X Lion, I forgot my password and Apple ID recoveries aren't enabled and I can't enable them as I don't know my password and my hint didn't help me at all, I really, really need help!

    Also, a solution may be found if you search in the "More Like This" section over in the right column.Solution may be found if you search in the "More Like This" section over in the right column.

  • Bought yearly subscription for Tech suite, unable to down load and installl/activate -need help-Vanita

    Hi there,
    I have bought yearly subscription for Tech suite which expires in May 2015, however I am unable to download or  install/activate it. I am paying monthly however cant use it!
    need help- Is there an email or phone number I can reach ---
    Thanks
    -Vanita

    BobLevine wrote:
    [....] If you find something out, please do come back and update us.
    Thanks for your willingness to help, but I got some great news!!!
    I finally managed to find the cause for that deactivation problem. It's called the "Update Root Certificates" component, which somehow was unchecked on my machine. Although I had previously installed the Adobe HTTPS (SSL) certificate for secure connections between my computer and Adobe servers, used while signing in on my account, each time I had to click YES to confirm manually that this certificate was valid and safe.
    Now, while deactivating from an application, such confirmation is not displayed and therefore the application considers a certificate (and thus connection as well) as invalid or unsafe. The result is: "Internet Not Found... Unable to Connect..." message.
    Here's what I did to fix it:
    1. clicked Start, and then pointed to Settings and then clicked Control Panel
    2. double-clicked Add or Remove Programs
    3. clicked Add/Remove Windows Components (on the left)
    4. scrolled down the list of components to Update Root Certificates, and checked the check box for that component
    5. clicked Next, and followed the instructions to complete the Windows Components Wizard.
    After turning that on, the deactivation was almost like a blink of an eye.
    So if anyone has a similar problem, make sure you have that system component turned on.
    Matt

  • Security Questions and Rescue Email "need help"

    The AppStore won't let me purchase anything and it keeps asking for my security question but I donn't remember it and the rescue email is not the one I choosed. Please somebody help I just added money to the account too need help A.S.A.P.

    You need to ask Apple to reset your security questions; this can be done by phoning AppleCare and asking for the Account Security team, or clicking here and picking a method, or if your country isn't listed in either article, filling out and submitting this form.
    They wouldn't be security questions if they could be bypassed without Apple verifying your identity.
    (106703)

  • Dynamic Forms and Flowing subforms -- Need help/Advice

    Hello All -
    I am creating a form for instructors at our college to complete. It has 3 pages, some static text, some required drop-down boxes, and three "comment" type areas which I would like to create so that they "flow" and display the entire contents when printed.
    I've read everything I could find so far, but I think I am missing something quite basic.
    I've created master pages, with a content subform on each one. I've placed all my content into subforms under that main content subform, named and ordered them the way they need to be. Most of it should appear as positioned. Only where there is one of the comment sections do I want/need the "flow content" option.
    I tried following the directions I found in another thread. If I set the subform with the comment area to flow, then I never get the page break option (and it is needed) - it's always grayed out. When I try to set the underlying subform on the page to 'flow content', ALL of the content from all three pages ends up on one page, everything on top of each other.
    What am I doing wrong?
    Can anyone give me some tips as to where at least to start looking for what I've not done or done wrong?
    Thanks in advance for any information -- it will be soooo appreciated!
    Lauren

    Hi Lauren,
    You only need one Master page, and there's no need to put anything on it unless you want a header/footer that repeats on each page.
    If you want to have things flow from page to page, create one body page object, and set its content type to Flowed (the body page is itself a subform). In it you put subforms with text, fields, and so on in them. Since your form will spill from page to page based on how much text the instructors type into the expandable comments fields, break up the forms content into sections (subforms) such that the layout can break between the subforms without taking away from the readability. These subforms should have a content type of Position. Even though there's only one body page object in your design, since you have three pages worth of stuff, it will spill onto three pages.
    Now for the comments fields, which you want to wrap and expand. Make sure that each of your comments fields is in its own subform. Set the field to allow multiple lines and, in the layout tab, click the box to Expand to Fit (height). For the subform that contains the comments field, set the height to auto-fit (layout tab). Also for the subforms that contain comments fields, experiment with the "Allow Page Breaks Within Content" checkbox on the Subform tab. If you expect an instructor to blab on for more than an entire page of text, you will have to select this box, but otherwise I suggest leaving it unselected so that the entire comment remains together.
    Jared Langdon
    www.jlangdon.ca

  • Problems with IOS 7.0.4 and ipad 2 need help

    Need help with problems caused by downloading IOS 7.0.4 onto my ipad2

    To answer, we'll need to know what problems you're having.

  • Error while transporting transformations and datasource Urgent need Help

    Hi all,
    I have been working on this problem for a few days now. I created an ODS object, transformations,  DTP and I am using a  R/3 datasource for extraction. The ODS populates fine in the Dev box, the tranformations and the datasource are fine only in the Dev box. I tried to tranport the objects to the QA box from the Dev Box. Only the ODS transports properly. The transformations are not transported at all. Here is the error I get:
    Start of the after-import method RS_TRFN_AFTER_IMPORT for object type(s) TRFN (Activation Mode)
    No rule exists
    Rule 1 of transformation   () is not valid and is being deleted
    Rule 2 of transformation   () is not valid and is being deleted
    Error occurred during post-handling RS_After_import for TRFN L
    Ended with return code : ==> 8 <===    
    Please do let me know what could be the problem. Please do respond ASAP......
    if you experienced this issue please let me know how you solved it or a possible work around. any help will be greatly appreciated....
    So far we have been using only 3.5 objects. This is the first 7.0 (end to End) transport.

    Hi voodi,
    I just followed the exact sequence that you mentioned. I transported the
    DataSource first....then ODS(write optimized)....then transformations....then Dtp & infopackage.
    data source  ... no errors
    2) ODS ..... no errors
    3) Transformations .... Error....same as mentioned in my earlier post....
    4) DTP and Infopackage ....Error  similar to whats mentioned ...and it says that transformation does not exist.
    Could it be an issue with Source System Translation .....  I dont know much about it .....could you please tell me what it could be and how to resolve it.   I am thinking in these lines because the source system in QA3 exists in the Data Souces Folder and it has  translated properly to QA3Client300. But under the Infoproviders folder (in Q03)...under my DSO the data source still shows Dev3Client 200(client not changed). If this is the issue do you think I need to talk to Basis support for asking them to modify the transport(internally)......can it be done....
    please do give me your feedback....thank you.

Maybe you are looking for