Jun 10, 2011

This is Java, not C/C++

Some things that are not working in Java. They have different syntax.
1. while(1) { .. } has equivalent while(true) { .. }
2. argv[0] contains the c/c++ executable name so index of the arguments starts from 1
args[0] contains the first argument and so on.
3. string ns(n) has equivalent String ns = Integer.toString(n);
4. string a, b; if (a > b) has equivalent if (a.compareTo(b) > 0) if they are equal it will give
0, if a>b then positive else negative.
5. sting a="hello world"; a[2] = 'e'; has its equivalent StringBuffer buf = new StringBuffer( s );buf.setCharAt( pos, c );return buf.toString( );
6. double d = static_cast(3); has equivalent double d = (double)3;
7. string s(3.99) has its equivalent String s = Double.toString(3.99);

No comments:

Carlo Cipolla's Laws of Stupidity

    "By creating a graph of Cipolla's two factors, we obtain four groups of people. Helpless people contribute to society but are...