A confusing piece of code, may be food for thought.

Looking at the following code it seems very obvious to me that the output should be 1010 but it turns out to be 2020. Could anybody explain the reason behind it?
public class TestClass
  public static void main(String args[ ] )
    TestClass tt = new TestClass();
    tt.ww();
  public void ww()
    Base b = new Base();
    Base b2 = new Base();
    b.iAge = 10;
    b2.iAge = 20;
    System.out.print(b.iAge);
    Integer iw = new Integer(b.iAge);
    col(iw);
  public static void col(Object o)
    Integer iw = (Integer) o;
    System.out.print(iw.intValue());
class Base
  public static int iAge;
}

Considering that the iAge member is 'static' (only one copy no matter how many instances of the object), and that you last set it to 20 before you output anything, what's to wonder about?

Similar Messages

  • Accessibility for the visually Impaired - food for thought

    Experts,
    Some food for thought:
    From a technical perspective, all I can imagine of as a solution to deliver accessible applications to visually impaired users of SAP, is an orchestrated screen design and cursor flow with complete keyboard navigability and minimum or zero click sensitivity.
    Have TTS/speech driven navigation or other alternatives been introduced in SAP already? If yes, what are the steps to be performed to harness the same in a typical SAP ERP Installation. Please enlighten me.
    Also, if you think this post is in the wrong forum, please let me know.
    Thanks in advance!
    NW

    Hi,
    Pls check below link.
    http://help.sap.com/saphelp_erp60_sp/helpdata/EN/af/94c0417546cd17e10000000a155106/content.htm
    Anil

  • Logic Crashing, food for thought...

    I posted this in another thread, but thought it might be worth posting separately.
    First, keeping in mind that crashes probably happen to Logic users all around the world running different versions on different computers with varying amounts of plugs, 3rd party apps, etc., and that not every Logic user is a member of an online forum... OK, having said that...
    Based on my casual observations reading through this most recent rash of crash complaints, I noticed that many of these posters are running the latest OS, 10.4.9. And I recently had an experience in another studio where, after installing Logic on a 10.4.9 computer that Logic crashed incessently.
    Anyway. So, my food for thought: has anyone found that they're crashing more often since updating to 10.4.9?

    MBP (core duo 1.83) all updates, no problems. Just ran some of the scenarios that others are reporting - it's as stable as ever.
    The only thing I've run across lately is Logic on the MBP not picking up my config from AMS. I have a G4 MDD in my studio, and I'm setting up to be able to switch systems with 1 usb and 1 firewire cable. The midi system is rather complex (40+ ports), and I spent my time working on my laptop.... then found Logic just ignores it. Works fine on the MDD - also running 10.4.9.
    but no crashes on either system... knock on wood.
    MBP 1.83 & MDD 1G DP   Mac OS X (10.4.8)   Logic Pro 7.2.3, Motu 828MkII+828, Firebox LC&XT, Tranzport, Unitor8+(3x)AMT-8's

  • O.T. Food For Thought

    Not something I would have thought any forum members are guilty of,but it does make you wonder how many adults of the future will know what they looked like when they were little :
    'In the U.K., the information security company Symantec commissioned a poll of 2,227 consumers that revealed 89% of them own a digital camera or cameraphone but about one-third of digicam owners don't back up their digital images. Not even with printsa large majority (70%) of digicam owners print 25% or less of their images and fully 30% said that they did not print out ANY hard copies. So, presumably many photographers are depending on their digicam memory cards or their PC's hard drive for storage, but memory cards can get lost or broken and ALL hard drives eventually fail.'

    Malcolm, Hi; I'm one that does not print much. I have a couple of external hard drives and I copy every thing on at least two sources. Most of my digital images and digital video gets put on CD, DVdisk or internet to share.
    Now that I'm getting into PSE I have been thinking about print again. When I do print I use Shutterfly or other on-line services. I have a good printer and a LCD monitor so I have been thinking about getting software to calibrate this monitor or using one of my old CRT monitors, since I have been reading about the difference in what you see on a LCD monitor and your print output. So far The prints I have made at home look good after I nudge up sliders on my printer preferences
    Some of the images I have been editing are looking good and I may not be satisfied with this method or on-line services any longer. Mickey

  • Food for thought : Closing I/O streams ....

    hi all,
    my intention is to release all the I/O streams after i have finished their use .to do it i call the .Close()
    method in a finally block .
    my question is : how is calling .Close() on an I/O stream different from, assigning a null to it .
    i.e. :
    objIOStream.Close();// in finally
    objIOStream = null; // in finally
    will the gc behave differently in these two cases ?
    what is the logical diffrence in the two approaches ?
    can i be sure that my streams would be closed/resources freed by using even the second approach ?
    thanks in advance,
    Ravi

    It's not quite the same thing.
    Closing the stream may cause it to set its internal stream to null but that doesn't mean that the outer stream becomes available for garbage collection.
    For example, in the following, outerStream doesn't gets garbage collected although it does get closed. When close is called, the FileInputStream that it wraps is closed and, according to your last post, the reference to it set to null - the FileInputStream should then be eligible for garbage collection. However, my Test class still maintains a reference to the BufferedInputStream thus preventing it from being garbage collected even though it can no longer do anything useful with it.
    public class Test
      private InputStream outerStream;
      public Test() throws Exception
        try
          outerStream = new BufferedInputStream(new FileInputStream("C:/blah.txt"));
        finally
          outerStream.close();
    }Explicitly setting objects to null in order to get them garbage collected is usually unnecessary, however. In the example above outerStream should have been declared locally in the constructor - it will then be eligible for garbage collection when it falls out of scope.
    Hope this helps.

  • Export puzzle--food for thought.

    Hi,
    I used to use FCE 2 on Panther and made a movie and used the export feature to make a DVD. I used "Export to QuickTime Movie" and made the thing self contained.
    After lots of time and upgrades (FCEHD 3.5.1, OS X Leopard, a new hard drive, etc,) I was having trouble with playing those old timelines. The rendered part were red indicating that they needed done even though I hadn't changed anything, so I figured I would render them fresh. I deleted my render files to save some space and just did it again. No problem.
    But now some of my old QT exports won't play, saying they are looking for these old rendered files. Weird, since I thought they could stand alone. Whatever, I'll just export them again, right? Here's the twist: the new exports are way bigger than the old ones. For example, a 90 second clip was 16.6 MB on FCE2, it is now 326.9 MB on FCEHD3.5.1 Does this have something to do with the HD part in the upgrade? Why is this new stuff so big?
    Perhaps I exported the old QT files using something else and compressed it, but I doubt it since the directions clearly state to do that and let iDVD compress it for me. And the info on the files look identical otherwise (codec, dimensions, open with FCE, etc). I'm guessing its just the difference between FCE2 and FCEHD3.5.1 exports. Am I right?
    Thanks,
    Ed

    You're probably right, although I could have sworn I made them self contained. But the signs seem to point to them being referrential. I guess I was wondering if i was possible that the new versions of FCE made things bigger by virtue of being "HD" and such.
    Thanks,

  • Just Food for Thought

    I think when my contract expires on 01/26/2013 that I will not renew my contract with VZW. I'll still remain with VZW, I'll pay the full-retail price for whatever glitzy device is all the rage. I figure, $800 FRP, without the threat of an ETF is well worth the peace of mind. I still pay the full price for the phone, just not upfront. 

    Verizon Bases the cost of the cell phone off of how much time your contract is, because part of the monthly bill actually goes to reimburse Verizon for the astronomical price of cell phones. Take the HTC Thunderbolt for instance with a 2 year contract they are going for $250 but the Full retail cost of the phone is about $650, if Verizon gets the guarantee from you that you will pay your bill for 2 years then they will sell you the phone at that cost because they will eventually get their money back. That is the whole reason for having contracts in the first place, So that average people can afford nice phones. Even the simplest phone in the line up like the Samsung Haven the full retail cost of that phone is like $175 and that is just a simple flip phone that doesn't Even have a camera. Who would pay that much for a phone? So in a sense you don't save any money by purchasing your phone at full retail because part of your bill will still go toward paying back a cell phone that you don't have a contract on. The only way you would save money is if you bought your phones from eBay or some 3rd party source, and then Verizon offer you an incentive and discount your plan for not purchasing phone through them. Since that isn't happening anytime soon, just sign the contract!

  • Food for thought: results differ when source compiled in JBuilder and Java

    Hi,
    I was working with JBuilder and i found that One of the JavaSource files which had a class attribute as final and was assigned somewhere later in a method, was getting compiled by JBuilder (as a member of a project), but the same class file while compiling with javac was giving compilation error.
    Also the size of the other class files on which i was working, generated by JBuilder and javac (Both are JDK 1.3) were different. How can there be a difference while compiling.
    If anybody can tell the reason.. i will be enlightened.
    Regards,
    Guru

    Your settings in JBuilder for how it compiles is probably set to compile with debugging allowed (command line -g), which will account for the size.
    As for your first problem, I can't help you. The only thing I can think of is that either JBuilder actually did not (re)compile that particular file or it's actually using a different compiler (e.g. jikes) that allows that kind of construct.

  • Food for thought

    I just checked the reconditioned Macs that Apple is selling on line and noticed most of the reconditioned fairly new Macs are selling with Snow Leopard as the operating system. Lion is only coming on computers with i5 and i7 processors. Hmmmmmmmmmmmmmmmm Very interesting!

    http://store.apple.com/us/browse/home/specialdeals/mac?mco=OTY2ODw
    I typed this because my browser wouldn't copy and paste for some reason. If it doesn't work simply go to the apple store on their web site (NOT the APP STORE, the store link on the apple web site) and look in the left lower column and you'll see a section for reconditioned Macs, iPads, iPhones, etc. I bought a reconditioned Macbook 3 years ago for $300 off new price and it works awesome to this day. In the future when looking for Mac products i'll ALWAYS buy reconditioned if what i want is available.

  • Food for thought: integrating SOAP in WLS6

    Looking at the multitude of questions regarding SOAP and WLS 6, I think
    the time has come to make some kind of HOWTO on integrating SOAP
    (especially apache's rpcrouter) in WLS 6.
    Like many others, I also have a strong need to make my EJB's available
    through SOAP in the very near future. My customers directly call EJB's.
    When they make Java apps, that's fairly straightforward and fast, but I
    also have clients requiring specific languages and runtime environments.
    What would I do when I want to make my EJB's directly available through
    SOAP?
    My guess is to:
    - install rpcrouter as a normal servlet in WLS;
    - write thin wrapper over the EJB's ("Provider Classes" in apache's
    rpcrouter admin);
    - define DeploymentDescriptors for these EJB-wrappers.
    The above is managable, but what about argument and return-type classes?
    These are all home-brewed and fairly complex (extending many classes and
    implemented many interfaces).
    The client at the other side needs class declarations and
    implementations if it is ever to pass one as an argument to a SOAP
    function call.
    In case of a Java client, I might give it these classes at forehand. In
    case of, say, a C-sharp app, this ain't an option.
    Another, even more fundamental problem is that of the interface -
    implementation abstraction: my EJB return-types and arguments are all
    interfaces. So the clients automatically use RMI to obtain an
    implementation at runtime. What about SOAP here? How do SOAP clients
    obtain implementations of these classes?
    Is there anyone (that includes you BEA) who can tell me more on this and
    even get me a working SOAP interface for my EJB's?
    Thanks in advance,
    Erik van Zijst

    I've seen that page. But it doesn't go deeper than the examples from
    apache and MS which I already ran.
    I can easily send strings and primitive datatypes to and from different
    languages. My trouble is with complex classes.
    Consider it the other way round: you are writing a Java app that needs
    to do rpc with a C# application. The return types of the remote methods
    are all complex classes. So you'll have to create stubs for them I
    guess. How do you do that?
    Erik
    Jane wrote:
    Check out the Developer Center...
    http://developer.bea.com/circuit/xml.html
    Jane
    Erik van Zijst <[email protected]> wrote:
    Looking at the multitude of questions regarding SOAP and WLS 6, I think
    the time has come to make some kind of HOWTO on integrating SOAP
    (especially apache's rpcrouter) in WLS 6.
    Like many others, I also have a strong need to make my EJB's available
    through SOAP in the very near future. My customers directly call EJB's.
    When they make Java apps, that's fairly straightforward and fast, but I
    also have clients requiring specific languages and runtime environments.
    What would I do when I want to make my EJB's directly available through
    SOAP?
    My guess is to:
    - install rpcrouter as a normal servlet in WLS;
    - write thin wrapper over the EJB's ("Provider Classes" in apache's
    rpcrouter admin);
    - define DeploymentDescriptors for these EJB-wrappers.
    The above is managable, but what about argument and return-type classes?
    These are all home-brewed and fairly complex (extending many classes and
    implemented many interfaces).
    The client at the other side needs class declarations and
    implementations if it is ever to pass one as an argument to a SOAP
    function call.
    In case of a Java client, I might give it these classes at forehand. In
    case of, say, a C-sharp app, this ain't an option.
    Another, even more fundamental problem is that of the interface -
    implementation abstraction: my EJB return-types and arguments are all
    interfaces. So the clients automatically use RMI to obtain an
    implementation at runtime. What about SOAP here? How do SOAP clients
    obtain implementations of these classes?
    Is there anyone (that includes you BEA) who can tell me more on this and
    even get me a working SOAP interface for my EJB's?
    Thanks in advance,
    Erik van Zijst

  • FB4 hidding pieces of code like in FlashCS5 or DWCS5 and earlier.

    Hi!
    Quick Q: for how to do this in FB4. I can hide pieces of code but only for whole functions where on the left side nice small button (with + or - sign) appears.
    What if i want to hide a piece of the code inside this function. If I choose portion of the code in Flash or DW automatically appear line ended with two boxes, after clicking one, my code is rolled up.
    So how can I do that in the FB4?
    Thank you for comment:)

    Please read the adult content warning in my original post...
    I was able to cure my problem after a bit of flailing around. This may not be a "problem"; it may result from a difference in the way Mozilla sees the end of a line of text vs. how IE sees it.
    Please refer to http://officialeventlocator.com/bdsm/state_pages/bdsm_ca.php to follow along...the page cited above has no data.
    I looked at all of the pages on the site that had information. I found that the error only occurred on pages where the field labeled "Other location information" was blank, and it ALWAYS happened when that field was blank. I do not understand why that caused a problem, but my solution was to alter my PHP script so that I avoided printing blank/null fields. It simply meant checking the field for a non-null value before printing, and the problem went away.
    Hope this helps someone else.
    Steve E.

  • I bought Photoshop CS6 Extended(education edition) for Mac. Now ik want to install it on my (new) macbook. I have the product code and serial number. I receive an error code: may be a false copy. How can I install this program?

    In 2012, I bought Photoshop CS6 Extended (education edition) for Mac. Now I want to install it on my new Macbook. I have the correct serial number and product code, but I receive an error message: the software may be a false copy etc....What to do?

    Here is a copy of the error
    This means : Installation failed.
    Verification of the Adobe Software failed
    The product you want to install is no valid Adobe product and seems to be falsified.
    HUgo
    Op 29-aug.-2014, om 23:42 heeft Jeff A Wright <[email protected]> het volgende geschreven:
    I bought Photoshop CS6 Extended(education edition) for Mac. Now ik want to install it on my (new) macbook. I have the product code and serial number. I receive an error code: may be a false copy. How can I install this program?
    created by Jeff A Wright in Downloading, Installing, Setting Up - View the full discussion
    Hugo please turn off your e-mail signature.
    If your serial number is listed as being valid at http://www.adobe.com/ then I would recommend obtaining a fresh copy of the installation files.  You can find details on how to locate your serial number at Find your serial number quickly - http://helpx.adobe.com/x-productkb/global/find-serial-number.html.
    To download a fresh copy of the installation files please see Download CS6 products.
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at https://forums.adobe.com/message/6685617#6685617
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:
    To unsubscribe from this thread, please visit the message page at . In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Downloading, Installing, Setting Up by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/thread/416458?tstart=0.

  • Why won't this piece of code work?

    Hello all, i am new to HTML and web design and i'm trying to make a website. I created this piece of code so that when the user mouses over one of the links (jpg image) it will change colors ( i have the same image in different color scheme saved in the same folder).
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>XXXXXXXXXX</title>
    </head>
    <body bgcolor="#000000">
    <table width="1050" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><table width="1050" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><img src="_images/XXXXbanner.jpg" width="1050" height="311" alt="banner" /></td>
          </tr>
        </table>
          <table width="901" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td width="150"><a href="index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('ButtonOne','','_images/home_on.jpg',1)">
                 <img name="ButtonOne" border="0" src="_images/home.jpg" width="150" height="75" alt="home" /></a></td>
              <td width="150"><a href="gallery.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('ButtonTwo','','_images/gallery_on.jpg',1)">
                  <img name="ButtonTwo" border="0" src="_images/gallery.jpg" width="150" height="75" alt="gallery" /></a></td>
              <td width="150"><a href="products.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('ButtonThree','','_images/product_on.jpg',1)">
                 <img name="ButtonThree" border="0" src="_images/product.jpg" width="150" height="75" alt="products" /></a></td>
              <td width="150"><a href="store.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('ButtonFour','','_images/shop_on.jpg',1)">
                 <img name="ButtonFour" border="0" src="_images/shop.jpg" width="150" height="75" alt="store" /></a></td>
              <td width="150"><a href="profile.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('ButtonFive','','_images/profile_on.jpg',1)">
                 <img name="ButtonFive" border="0" src="_images/profile.jpg" width="150" height="75" alt="profile" /></a></td>
              <td width="151"><a href="contactus.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('ButtonSix','','_images/contact_us_on.jpg',1)">
              <img name="ButtonSix" border="0" src="_images/contact_us.jpg" width="150" height="75" alt="contact" /></a></td>
            </tr>
          </table>
          <table width="1050" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td> </td>
              <td> </td>
              <td> </td>
            </tr>
          </table>
          <p> </p>
        <p> </p></td>
      </tr>
    </table>
    </body>
    </html>
    the images and banner are showing up fine and i havent mistpyed any of the locations/file names. why doesn't the icon change colors (display the "on" image) when u hover the mouse over it? please help thanks in advance.
    ** i'm using Adobe Dreamweaver CS4

    He's right...
    try instering this into the head tags of your html
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    //-->
    </script>

  • What's the logic error in this piece of  code?

    Hello All:
    I am doing a simple program dealing with restaurant operation. The problem is that when customer click check out button, the status of the corresponding table object doesn't change to "Vacant", whereas it should as according to my design.
    Following is the piece of code from the Interface class, where check out button (outB) is declared and add with an ActionListener:
    pCentre.setLayout(new GridLayout(3,2));
         outL = new Label("Pls type your table number to check out");
         outTable = new TextField(30);
         outMsg = new TextField(30);
         outB = new Button("Check Out");
         outB.addActionListener(new ActionListener(){
              public void actionPerformed(ActionEvent e)
              int tbNo = Integer.parseInt(outTable.getText());
              if (tbNo<1 || tbNo>5)
                   outMsg.setText("This table doesn't exist!");
              else
                   outMsg.setText("Thank you. See you again.");
    proc.checkout(tbNo);
              }// proc is the handler of Processor Class, which contain the checkout method.
    this is Processor class:
    public class Processor
    DataStore ds;
    public Processor()
    ds = new DataStore();
    public int searchTable(CusmInfo ci)
    for (int i=0; i<5; i++)
         if((ds.tInfo.tCap > ci.cNo) &&
         (ds.tInfo[i].tStat.equals("Vacant")))
         ds.tInfo[i].tStat = ci.name;
              return i+1;
         return -1;
         public String check(int i)
         if(i<1 || i>5)
         return("Table number exceeded");
    else
         return ds.tInfo[i-1].tStat;
    public void checkout(int i)
         ds.tInfo[i-1].tStat = "Vacant";     
    This is DataStore class which caters for table objects:
    public class DataStore
    public TableInfo[] tInfo = new TableInfo[5];
    public DataStore()
    tInfo[0] = new TableInfo(1, 4, "Vacant");
    tInfo[1] = new TableInfo(2, 4, "Vacant");
    tInfo[2] = new TableInfo(3, 6, "Occupy");
    tInfo[3] = new TableInfo(4, 6, "Occupy");
    tInfo[4] = new TableInfo(5, 8, "Vacant");
    public TableInfo getTableInfo(int i)
    return tInfo[i];
    class TableInfo
    int tNo;
    int tCap;
    String tStat;
    public TableInfo(int n, int c, String s)
    tNo = n;
         tCap = c;
         tStat = s;
    Why is it that after clicking the outB button, the status of the table is still customer's name but not "vacant". It seems the checkout method doesn't work. Is it because we can change the attribute of table object directly? BTW, the rest of methods in Prossor class all work properly.      

    Lol, "piece" of code is good...
    First, you should encapsule your code in "code" tags ([_code_] and [_/code_] w/o the underscores) so it will be much more readable.
    Then maybe you should assign some dukedollars to attract people to do the work for you. This is not an easy one-minute-thought question like "I'm new to java how do i print out text to stdout?" ....
    Do that and I'll check back to have a look...

  • Piece of code that is getting executed in determining vprs in billing

    Hi,
    I am a functional consultant and I desperatley need your help in finding out the piece of code that is responsible in calculating the value for VPRS condition in billing document. Its a special condition type(with condition category G) whose value is determined in the background by SAP. Generally the business scenario is like this
    SALES ORDER-DELIVERY DOCUMENT-BILLING.
    of course there are so many sources for the system to find out the value for VPRS  like from material master,sales order and material document .
    please give me the set of lines in the standard program which are relvant for this calculation because system is not behaving in a what SAP is saying .
    Thanks in advance.
    Ravi

    Can you post your bean and exception code? Is your exception checked or unchecked exception? If logMsg method throws an application exception, it should be thrown to the calling MDB as is.
    -cheng

Maybe you are looking for