J2ME优化程序的一些小技巧----Gaming with MIDP2.0

博客介绍了J2ME编程的优化技巧,如用StringBuffer代替String,直接访问类变量,使用局部变量,避免循环同步,使用复合运算符,移除循环中的常量计算,重用对象,将未使用对象赋值为null,优先使用内置方法等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. Use StringBuffer instead of String because of the fact the String object can not 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 x += 1 instead o f x = x + 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 then likely this method will be more efficient then the one you created yourself
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值