Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This <a href="http://crfdesign.net/programming/top-10-differences-between-java-and-c" rel="noreferrer">guy here</a> had to make the inverse transition. So he listed the top 10 differences of Java and C#. I'll take his topics and show how it is made in Java:</p> <h2>Gotcha #10 - Give me my standard output!</h2> <p>To print to the standard output in Java:</p> <pre><code>System.out.println("Hello"); </code></pre> <h2>Gotcha #9 - Namespaces == Freedom</h2> <p>In Java you don't have the freedom of namespaces. The folder structure of your class must match the package name. For example, a class in the package <em>org.test</em> must be in the folder <em>org/test</em></p> <h2>Gotcha #8 - What happened to super?</h2> <p>In Java to refer to the superclass you use the reserved word <code>super</code> instead of <code>base</code></p> <h2>Gotcha #7 - Chaining constructors to a base constructor</h2> <p>You don't have this in Java. You have to call the constructor by yourself</p> <h2>Gotcha #6 - Dagnabit, how do I subclass an existing class?</h2> <p>To subclass a class in Java do this:</p> <pre><code>public class A extends B { } </code></pre> <p>That means class <code>A</code> is a subclass of class <code>B</code>. In C# would be <code>class A : B</code></p> <h2>Gotcha #5 - Why don’t constants remain constant?</h2> <p>To define a constant in Java use the keyword <code>final</code> instead of <code>const</code></p> <h2>Gotcha #4 - Where is <code>ArrayList</code>, <code>Vector</code> or <code>Hashtable</code>?</h2> <p>The most used data structures in java are <code>HashSet</code>, <code>ArrayList</code> and <code>HashMap</code>. They implement <code>Set</code>, <code>List</code> and <code>Map</code>. Of course, there is a bunch more. Read more about collections <a href="http://java.sun.com/docs/books/tutorial/collections/index.html" rel="noreferrer">here</a></p> <h2>Gotcha #3 - Of Accessors and Mutators (Getters and Setters)</h2> <p>You don't have the properties facility in Java. You have to declare the gets and sets methods for yourself. Of course, most IDEs can do that automatically.</p> <h2>Gotcha #2 - Can't I override!?</h2> <p>You don't have to declare a method <code>virtual</code> in Java. All methods - except those declared <code>final</code> - can be overridden in Java.</p> <h2>And the #1 gotcha…</h2> <p>In Java the primitive types <code>int</code>, <code>float</code>, <code>double</code>, <code>char</code> and <code>long</code> are not <code>Object</code>s like in C#. All of them have a respective object representation, like <code>Integer</code>, <code>Float</code>, <code>Double</code>, etc.</p> <p>That's it. Don't forget to see <a href="http://crfdesign.net/programming/top-10-differences-between-java-and-c" rel="noreferrer">the original link</a>, there's a more detailed discussion.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload