The following tips are only suggestions and may or may not give gains in performance, it is to your own judgment and discretion to use them or not.
1. Use StringBuffer instead of String because of the fact the String object cannot be changed. Any modification to a String variable is actually a new object creation.
2. Accessing class variables directly is faster then using setter and getter methods.
3. Using local variables are more efficient then instance/class variables
4. Using variables are more efficient then arrays.
5. Avoid synchronization in loops because there is an extra over head to lock and unlock each time the loop occurs
6. Counting down in loops is faster then counting up
7. Use compound operators like × += 1 instead o f × = × + 1 because fewer byte codes is generated
8. Remove constant calculations in loops
9. Reuse objects
10. Assign null to unused objects, especially unused threads
11. Try to use already built in methods, for example if you want to copy data from one array to another use
System.arraycopy more thenbe more efficient then the one you created yourself
Game applications with JAVA(TM)
Now, the gaming application for small devices is easy and fun with new MIDP 2.0 API. The biggest difference for a game developer between MIDP 1.0 and MIDP 2.0 lies with the enhanced graphics capabilities. With MIDP 1.0 you can
certainly write some fun games—those of us.
||Now with the 2.0 version, the Mobile Information Device Profile doesn’t bring to the level of the latest game cube, but it brings the user’s cell phone to the realm of Super Mario Brothers or there about.
A MIDlet is very much like an applet except that it runs on a mobile device rather than in a browser.
The directory structure of the gaming application consists of the following:
• src, containing source code
• bin, containing the manifest.mf file, JAD file, and JAR file
• classes, containing the compiled classes
• res, containing image, data, and other files required by the applicationJ2ME BASICS
Programming with MIDlet is very much similar to creating a J2SE application. However, a MIDlet is less robust than a J2SE application as there exist a lot of restrictions, imposed by the small computing devices.
Let’s illustrate the details of developing a simplest MIDlet program i.e. A Hello World program in the Java platform ME Style.
A MIDlet is a java class which extends the MIDlet class. It acts as an interface between an application statements and the run-time environment (controlled by the application Manager). A MIDlet class should contain 3 abstract methods that are used to manage the life cycle of the MIDlet by the application manager. These abstract methods
2007 | Java Jazz Up |14
|View All Topics
|All Pages of this Issue
69 Download PDF