Is it a bug in Java or Visual C ????????

Hi
There is a problem in this mathematical expresasion.
int a=10;
a=a++ -10;
this gives a value zero in Java while the same code gives a=1 in Visual C.
Why there is differnt result? where would the value of a (after increment) goes in case of Java??
Thanks

Programmer is a programmer whether writes in java
or cobol language.That's somewhat true, but it has nothing to do with this. Two different programming languages could use the same symbol in different ways. Things are different between languages.
It like that in many areas. 'die' is a verb in English, or 'the' in German. The same thought can require a different symbols in different languages. The thought is the same, but just because the words look similar doesn't mean they are
If you didn't need to know how to do things differently in one language vs. another, wouldn't that mean that if you can program in one, you can program in any language without knowing the differences in the two languages just because you are a 'programmer'
You can still apply the same logic to programs in different languages, but implementing that logic in the specific syntax of a particular programming language is programming.

Similar Messages

  • A bug in Java

    I would like to report a bug in Java.
    It began with the rmi tutorial on computing pi.
    I had no problem with this on a single computer but could never get it to work over the network. I posted messages on this forum and got lots of generous help, especially from Genady, but eventually I left it as an unsolved problem.
    Yesterday I came back to my local network with my current problem and had problems similar to pi. Now at least I have more experience and I could track it down. It looks like a Java bug to me.
    The hardware is: 1 router, behind which sit 2 computers: home-ilan at 192.168.2.100 and home-yona at 192.168.2.103. I have a client-server setup via rmi. If the server is on home-yona, all works OK. If the server is on home-ilan it fails. What could be the difference?
    It turns out that home-ilan (my main computer) also has the possibility to run VPN to the hospital. The VPN uses a given IP. If I need to get to the hospital, I use the VPN. If not, I don't use it.
    Yesterday I put Eclipse on home-yona and looked for the problem. It turns out to be in
    Query q1 = (Query) Naming.lookup(rmi1);I was running the query from home-yona to home-ilan. I got a valid q1 back, and I drilled down into it. One of the elements is
    ep=TCPEndpoint which has a host value.
    The host value should have been 192.168.2.100, but instead it was the value of the VPN. The packet was sent from 192.168.2.100 to 192.168.2.103 and home-yona picked up the packet correctly, but it had the wrong value of the host. When I actually made the query to rmi, it expected the result from the VPN IP, which it never got, so it timed out.
    The bug is that Naming.lookup, even though it got the packet through the LAN, gave VPN address. This would have been fine had I been querying from the hospital, but I was in fact doing a local query. The Naming.lookup doesn't differentiate, which is a bug.
    The bug is 100% reproducible. If I start the server while VPN is running, from home-yona I will always get the VPN IP. If I start the server while VPN is turned off, I will get the correct address.
    Any suggestions?
    Ilan

    If that were the only thing which was wrong, we'd be in great shape. It is then a bug of Cisco Systems who supplied the VPN. I just took the default conditions and used them. I had no idea there was any problem until I ran the RMI protocol.
    In fairness to Cisco Systems, I must say that it is unusal to say that I want a VPN connection into the hospital and at the same time make a connection over my local LAN. In fact it works for everything I happened to try up until now, but it fails for RMI (because of the static assignment).
    The amazing thing is that with all these incompatible programs is not that sometimes it fails, but that it works at all. When I look at the Control Panel, I see 2 LAN connections, my local LAN and the VPN. I suspect I would have a very similar problem if I had 2 physical LAN cards.
    The home-ilan identifies the computer and it doesn't identify the computer-lan combination.
    What the RMI wants is not the computer identification, but rather the lan card identification. At least in the Control Panel, such a thing doesn't exist.

  • Is this a bug in Java!

    int i=0;
    i=i++;
    System.out.println(i);
    What should this code print.
    I guess 1.
    But it prints 0.
    Can anyone explain the logic behind this, or is this a bug in Java.
    Thanks for your time in advance.

    What did the mackerel do to deserve that?it wrote Sun's search function !!!!!! :pPlease, a mackerel would of done a better job.
    All I can say is "JTable project", smiles.
    (Gah, Please kill me)mlk BANG BANG*
    *Post decease operator.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Java or Visual C++

    I must choose between Java and Visual C++ to write an application running on a windows / linux doing
    - display of windows / pictures
    - database access (flat files)
    - TCP networking (client)
    I know already VC++ and being in the process of learning Java.
    Question: besides cost and speed performances, what VC++ can do that Java cannot perform?
    Thanks

    The main reason to choose Java is because of the Java platform itself. Rapid development, rich API set, easy debugging and no Microsoft policies that force you to port code when they release a new version of their platform. For the three tasks you mention Java has very easy to use API's readily available:
    - windows/pictures -> Java SWING and Advanced Imaging / ImageIO
    - database access -> JDBC
    - TCP networking -> Java sockets, either regular stream IO or the more powerful NIO
    Check out these threads to see how easy it is:
    Swing: http://java.sun.com/docs/books/tutorial/uiswing/index.html
    sockets: http://java.sun.com/docs/books/tutorial/networking/sockets/index.html

  • Bug in Java

    Hi Guys ,
    i found a bug in java when doing this calculation..
    double a = 1741;
           double b = 81.1;
           double c = 0;
           double temp = (a-b-c);
           System.out.println("temp = "+temp);  //1659.9
           double total = (double)temp/1000;   //BUG HERE
           System.out.println("Res = "+total);  //1.6599000000000002I wonder if u guys get the same value as mine using above calculation.
    if i change the double b = 81.2 i works fine..

    I have good news and bad news for you. To end on a high note we'll leave the good news for last.
    The bad news is that you are the 6,137,215th person to report this "bug" yet Sun will not be fixing it.
    The good news is that the bad news doesn't matter because... <drumroll please/>.....
    It is NOT a bug. The only bug here is your lack of understanding floating point arithmetic. I refer you to the following article http://docs.sun.com/source/806-3568/ncg_goldberg.html

  • A possible *bug* in java jcombobox

    Hi all,
    I think i found a possible bug in java jcombobox .. i am sure some of you must have already experienced it..
    supposedly you put a jcombobox in a jpanel
    returned the panel from a method to a calling method..
    and that method adds it to another panel that it had created to a frame..
    and if this happens dynamicaly at runtime, as only after u click a button..
    meaning : without adding the combobox or the immediate parent panelto the contentpane .. directly..
    Then,
    your combox's keylistener may not catch events fired.
    .. this has happened to me many times.. and always i could only find a way out
    .. by adding the combobox to panel that is loaded during startup itself and is
    .. not returned through a method call.
    Your opinions please ?
    'Harish.

    All components in a UI are created at run-time.
    When you create your JFrame you call pack() to align and resize the UI. This validates all the components, and sets the default focus on what ever component should have the focus at start up.
    When you create components and add them as children of another component you have to validate the child and parent. This can be done by calling JComponent.validate()
    As for keylisteners not getting called, this might be fixed if you call grabFocus on the new combobox. I can't see a reason why any listener would stop working.
    For me to really understand what your talking about. I'd need to see source code reproducing this problem.

  • Bug in java arrays?

    Hi, just found this in a toy program and thought it might be a bug in the way java handles arrays... I'm working on Suse 8.0 & jdk 1.4, Red Hat 7.x/8.x with jdk 1.4 and Solaris 4 jdk 1.4:
    If you have a method like this:
        public static void resize(int[] arr, int size) {
            int[] tmp = arr;
            int iterate;
            arr = new int[size];  // disassociate tmp from arr
            iterate = size > tmp.length ? tmp.length : size;
            for(int x = 0; x < iterate; x++) {
                arr[x] = tmp[x];
        }and try to call it from another class like this:
            /* could this possibly be a bug in java??? */
            Arrays.resize(state, state.length + 1);  // make array bigger
            state[state.length - 1] = start;  // store current room in arrayI get an ArrayIndexOutOfBoundsException on the call to assign start to the last index of state, which means that the new array knows its new length, but can't assign to it.
    The solution to my problem was to return arr in the resize() method and assign the returned value to state.
    This seems to go against what its supposed to happen (that the array is rezized and the pointer just updated)
    Is this a bug in java or is it te desired behaviour?
    dave.

    But when I create the 'new' array I'm assigning the
    pointer to the place where the previous array pointer
    was... This should be completely legal. Yes, it's completely legal, but it doesn't do what you want :)
    The variable in method to which you assign a new and longer array is a different one than the pointer you have in another method.
    If you just call a function to assign values to an
    array like this:> public void update(int[]arr){
    arr[0] = 2;
    } > and then use some code to look at the array you
    passed: > int[]x = {1,2,3,4};
    update(x);
    system.out.println(x[0]);> you would expect to get 2 in the
    output. Whay should this operation be different?Because in this case you wrap the reference you change (slot 0 in the array) into another object (the array). Therefore the reference you actually change is the same as the reference you expect to change.
    If you let your resize method return the new and longer array, and assign the returned value to yor old variable, you might get a better result.
    (And System.arraycopy may be more efficient than your for loop.)

  • Any way to comment or watch a bug for Java???

    Hello!
    AFAIK, at bugs.sun.com it isn't possible to comment on bugs, watch them or vote for them anymore.
    I found out there's now https://bugs.openjdk.java.net but I can't find any way to register.
    So, how the hell I can follow the progress on bugs? Or add additional information if I have?
    It's unbelievable that in 2013 we are still unable to have a decent bug reporting system for the JDK/JRE!!!!!
    Mauro.
    P.S.: I know this might not be the best section for this kind of question, but I couldn't find anything better in these forums...

    Other than physically looking for it, sorry, no.

  • How do I report a bug for SAP 3D Visual Viewer?

    How do I report a bug for SAP 3D Visual Viewer?
    I have version 8.0.100.27428, Jun 18 2014

    Hi Ellen,
    Hope you are doing good.
    The best option would be to raise a OSS incident in the component: CA-VE-VEV or CA-VE-CAD so that my colleagues can actually investigate this further and release a bug patch if needed.
    Thank you!
    Kind Regards,
    Hemanth
    SAP AGS

  • A bug of java plugin

    If you uncheck cache enabled option on "Java Applet Cache Viewer" from Java Console, you will find JavaPlugin not sending "Accept-Encoding" HTTP head to web server any more. So the plugin cannot load *.jar.pack.gz from server.
    I think this is a bug. Do you think so?
    I found this problem under JRE 1.5.06 and IE/Firefox enviroment.
    Pls send any question about this to [email protected] Thanks.

    Yes, it looks like a bug in Java 5 (1.5.0_xx).
    The problem does not exists in Java 6 though. Have you tried Java 6 ?
    Also, in the upcoming new 6u10 consumer release, there is a new feature that allows you to use pack200 compressed JAR with java web start or java plugin, without any server side requirements (you don't need to run a servlet anymore!):
    https://jdk6.dev.java.net/testProperty.html
    You can download 6u10 early access builds here: http://download.java.net/jdk6/binaries/
    Thomas Ng
    Java Deployment Team

  • [ASK]Bugs of Java or Wrong Code?

    Dear All,
    What this is bugs of Java or me not to understand java programming, this my piece code :
    String kode = txtKode.getText();
            String nama = inputNama.getText();
            String keterangan = inputKeterangan.getText();
            try {
                Connection c = KoneksiMySql.getKoneksi();
                String sql = "UPDATE UNIT SET NAMA=?, KETERANGAN=?, WKT_INPUT=now() WHERE KODE=?";
                PreparedStatement p = c.prepareStatement(sql);
                p.setString(1, nama);
                p.setString(2, keterangan);
                p.setString(3, kode);
                p.executeUpdate();
                p.close();
                JOptionPane.showMessageDialog(null, "Data Berubah",
                        "Pemberitahuan", JOptionPane.INFORMATION_MESSAGE);
            } catch(SQLException e) {
                System.out.println("Error : " + e);
                JOptionPane.showMessageDialog(null, "Proses Rubah Unit Gagal",
                        "Pesan Error", JOptionPane.ERROR_MESSAGE);      
            }finally {
            inputNama.setText(null);
            inputKeterangan.setText(null);
                btnTambah.setEnable(true);
                btnHapus.setEnabled(false);
                btnRubah.setEnabled(false);
                inputNama.requestFocus();
    JOptionPane is Show and no error appears but data in database does not change, and code in block finally not executed.
    i'm use jInternalFrame, first run Only 'Add Button, Search Button' enable and other button are disable, then when 'Search Button' is clicked and open other jInternalFrame and get data form database, 'Add button' Disable and 'Delete Button, Change Button' are Enable. that my piece code on Change Button ActionPerformed.
    Please it's support.
    Thanks,
    Best & Regrads.

    Cross posted
    [ASK]Bugs of Java or Wrong Code?
    [HELP]Bugs of Java or Wrong Code?
    db

  • Bug in java.awt.geom.Line2D?

    The method,
    public static double ptLineDistSq(double X1,
                                      double Y1,
                                      double X2,
                                      double Y2,
                                      double PX,
                                      double PY)calculates the squared distance between a line segment and a point.
    If however you pass in a line segment of zero length (X1=X2, Y1=Y2), the method performs a div by zero, which causes NaN to be returned.
    I believe this is a bug, as the method makes no exceptions to valid input, also mathmatically the distance from a point to a line segment still has a value even if the line segment has a zero length.
    A simple sanity check at the start of the method would fix it,
    if(X1==X2 && Y1==Y2) return (X1-PX)*(X1-PX)+(Y1-PY)*(Y1-PY);

    Yeah, im already working around it (i've actually just stolen their code, and switched it all from doubles to floats :D - it isn't a serious app. just a problem I encountered when answering a question in this Thread http://forum.java.sun.com/thread.jsp?forum=406&thread=420363&start=30&range=15&tstart=0&trange=15)
    I was realy just posting here for confirmation that it is a bug, before I reported it.

  • Bug In Java 5 Date/Calendar Timezone Implementation (possibly 6 also)

    Hey All,
    Really been scratching my head over a date issue I've observed for a while now in relation to TimeZone handling in java.
    It first manifested itself as strange behaviour in my Default TimeZone "Europe/Dublin" (ie. GMT with DST)
    e.g:
    System.setProperty("user.timezone", "Europe/Dublin");
    Date epoch=new Date(0);
    System.out.println("Epoch:"+epoch);
    yields:
    Epoch:Thu Jan 01 01:00:00 GMT 1970
    1AM (BUG???????)
    If I set the TZone above to GMT it outputs correctly as
    Epoch:Thu Jan 01 00:00:00 GMT 1970
    As there is no offset from GMT I can only think that DST is being handled incorrectly around the epoch. (even though it is not in DST on Jan 1st)
    So I wrote the following test using calendars to test my theory.
              System.setProperty("user.timezone", "UTC");
              Calendar test=Calendar.getInstance(); //will use the user.timezone
              Calendar test2=Calendar.getInstance(TimeZone.getTimeZone("Europe/Dublin"));
              for (int year=1965;(year<=1975);year++){
                   test.clear();test2.clear();
                   test.set(year, 0, 1, 0, 0, 0);
                   test2.set(year, 0, 1, 0, 0, 0);
                   System.out.println("UTC:"+ test.getTime()+ " --- EU/Dub:"+test2.getTime());
    Which yields the following interestingly inconsistent output (BUG?????)
    UTC:Fri Jan 01 00:00:00 UTC 1965 --- EU/Dub:Fri Jan 01 00:00:00 UTC 1965
    UTC:Sat Jan 01 00:00:00 UTC 1966 --- EU/Dub:Sat Jan 01 00:00:00 UTC 1966
    UTC:Sun Jan 01 00:00:00 UTC 1967 --- EU/Dub:Sun Jan 01 00:00:00 UTC 1967
    UTC:Mon Jan 01 00:00:00 UTC 1968 --- EU/Dub:Mon Jan 01 00:00:00 UTC 1968
    UTC:Wed Jan 01 00:00:00 UTC 1969 --- EU/Dub:Tue Dec 31 23:00:00 UTC 1968
    UTC:Thu Jan 01 00:00:00 UTC 1970 --- EU/Dub:Wed Dec 31 23:00:00 UTC 1969
    UTC:Fri Jan 01 00:00:00 UTC 1971 --- EU/Dub:Thu Dec 31 23:00:00 UTC 1970
    UTC:Sat Jan 01 00:00:00 UTC 1972 --- EU/Dub:Sat Jan 01 00:00:00 UTC 1972
    UTC:Mon Jan 01 00:00:00 UTC 1973 --- EU/Dub:Mon Jan 01 00:00:00 UTC 1973
    UTC:Tue Jan 01 00:00:00 UTC 1974 --- EU/Dub:Tue Jan 01 00:00:00 UTC 1974
    UTC:Wed Jan 01 00:00:00 UTC 1975 --- EU/Dub:Wed Jan 01 00:00:00 UTC 1975
    Strange - ehh? 1969->1971 all have issues with the Jan 1st date!!!!
    In fact theres issues for every day that DST is not in operation on these years... (BUG????)
    I'm part of a project that will be handling data from all Timezones and as such we have chosen
    to use UTC as our server time. We are now quite concerned what other bugs/strange behaviours
    lurk beneath the surface of the java implementation.
    Note we have tested various JDK's and they seem to be consistently inconsistent!
    If anyone can confrim this bug/issue or shed any light it would be most appreciated,
    G.

    miniman wrote:
    As there is no offset from GMT I can only think that DST is being handled incorrectly around the epoch. (even though it is not in DST on Jan 1st)Well, in the UK, DST was in effect on 1970 Jan 01. I wouldn't be surprised to find that the same applied in Ireland.

  • Java swing/visual components in an Oracle Form

    Hello,
    Has someone used visual javabeans embedded in Oracle Forms ?
    is there a special api or componente to use?
    I want to embed a jclass javabean in an Oracle Form (oracle forms client)
    any help will be welcome, thanks

    There are examples of white papers on OTN which show how you can integrate Java Beans into the Forms UI.
    You may have some success with Swing but forms is based on AWT/EWT of which there was only and old (and not
    very good) Swing version.
    As I said - check out the white papers and you can try the demos which are on the Sample Code page.
    Regards
    Grant Ronald
    Forms Product Management

  • Bug in Java objects not serializable

    I plan to use the latest version TopLink 10.1.3.1.0 with Oracle Database 10g (10.2.x).
    Do I still have to use the “Type Conversion” mapping as I had to do in order to address the reported non-serializable bug exiting in TopLink (9.0.4.5). See the link for the bug description:
    http://www.oracle.com/technology/documentation/1012_solaris/relnotes.1012/relnotes/toplink.htm#CEGEBDEG
    My Java object instance variable is defined as java.sql.Timestamp and the corresponding data type on the Oracle DB is defined as TIMESTAMP(6). Can I use the direct-to-field mapping from now on with new TopLink 10.1.3.1.0 without the serializable issue? If I still have to use the Type Conversion mapping, please help provide some detail about the mapping.
    Many thanks for any help.

    From what I can understand from your reply, I can use the direct-to-field mapping for Java class attribute of java.sql.Timestamp to the Oracle DB 10.2.x data type of TIMESTAMP(6) without any issue of not serializable. Please confirm. Many thanks!
    By the way, I am having the same issue (Java objects not serializable) with Oracle DB 10.1.x when I use the direct-to-field mapping. It seems to me that this is more than the Oracle 9i JDBC driver.
    If I have to do this with TopLink 10.1.3.1.0 + Oracle 10.2.x, I plan to use the Type Conversion with:
    Java class attribute: java.sql.Timestamp
    DB data type: oracle.sql.TIMESTAMP
    Is this the proper way to do it? Please confirm.

Maybe you are looking for

  • Samsung Galaxy Note 10.1 2014 Edition; Wireless Direct Printing Issues

    Good day everyone. The subject refers. I have been trying to connect my tablet to my hp printer (LaserJet Pro 200 color MFP M276nw) using wireless direct printing without success. What normally happens is when I try to detect the printer through wifi

  • Permissions repair takes hours, never finishes

    I've been doing some looking around the forums but haven't found an answer to my question. PROBLEM: Permissions repair takes FOREVER. I started a permissions repair task on the startup drive yesterday afternoon and it hadn't finished by this morning.

  • Unable to install AIA FP 11.1.1.6 on Linux successfully

    Hi All, I am installing AIA FP 11.1.1.6 on top of SOA suite 11.1.1.6. My SOA suite installation is sucessful and I am able to deploy SOA composites on the soa server. After verifying this I started AIA FP installation on the same Linux server through

  • Editable Recursive Tree

    hi evreyone I need to create an editable tree based on (one table called Locations) this is the structure of this table LocationNo LocationName ParentLocationNo LocationNo and ParentLocationNo are Forign keys according to what I've red I should use a

  • Creating XML format

    Hi  All, Can anyone please explain what is the difference between creating an XML format from an internal table using  CALL TRANSFORMATION and using CLASS BUILDER? In  class builder  we have  to Create the main iXML factory , then Create a stream fac