I've recently started developing applications for the Blackberry. Consequently, I've had to jump to Java-ME and learn that and its associated tools. The syntax is easy, but I keep having issues with various gotchas and the environment.
For instance, something that surprised me and wasted a lot of time is absence of real properties on a class object (something I assumed all OOP languages had). There are many gotchas. I've been to various places where they compare Java syntax vs C#, but there don't seem to be any sites that tell of things to look out for when moving to Java.
The environment is a whole other issue all together. The Blackberry IDE is simply horrible. The look reminds me Borland C++ for Windows 3.1 - it's that outdated. Some of the other issues included spotty intellisense, weak debugging, etc... Blackberry does have a beta of the Eclipse plugin, but without debugging support, it's just an editor with fancy refactoring tools.
So, any advice on how to blend in to Java-ME?
This guy here 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:
To print to the standard output in Java:
System.out.println("Hello");
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 org.test must be in the folder org/test
In Java to refer to the superclass you use the reserved word super
instead of base
You don't have this in Java. You have to call the constructor by yourself
To subclass a class in Java do this:
public class A extends B { }
That means class A
is a subclass of class B
. In C# would be class A : B
To define a constant in Java use the keyword final
instead of const
ArrayList
, Vector
or Hashtable
?The most used data structures in java are HashSet
, ArrayList
and HashMap
. They implement Set
, List
and Map
. Of course, there is a bunch more. Read more about collections here
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.
You don't have to declare a method virtual
in Java. All methods - except those declared final
- can be overridden in Java.
In Java the primitive types int
, float
, double
, char
and long
are not Object
s like in C#. All of them have a respective object representation, like Integer
, Float
, Double
, etc.
That's it. Don't forget to see the original link, there's a more detailed discussion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With