What does Java differ from c/c++?

1. The file name must match the class name.

2. The char type is 16-bits.

3. Support new "normal logical operators", such as "&" and "|".

4. Don't support the same variable name between different scopes.

5. From JDK 7, the expression controlling the switch could be type String.

6.Support a goto style break, i.e. " break label"; support same kind of continue, i.e. "continue label".

7. No c/c++ pointer, all object variables are reference.

8. If class method has no parameters, the parameter list will be empty, NOT "void".

9. No explicit destructors, finilize() method would be called before garbage collection.

10. Arrays are implemented as objects.

11.Irregular arrays supports sparsely array.

12. Two form of array declaration syntax: int counter[] = new int[3];   int[] counter = new int[3];

13. Array supports length member, length member gives the capability of the array.

14. String.equals(str) is not same as == operator. 

The equals() method compares the character sequences of two String objects for equality. Applying to == to two String references simply determines whether the two references refer to the same object.

15. Strings are immutable.

16. Class support static block which is executed before the object is created ,and before constructor.

17. Support nested and inner class, and anonymous class.

18. Java does not support the inheritance of multiple superclasses into a single subclass. However, it supports the inheritance of multiple interfaces.

19. Use super to call superclass constructor, superclass members.

20. Java support the abstract method, the containing class must be abstract also.

21. final prevents overriding, inheritance,  and can be used to  define a constant similar as #define in C.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值