首页 > 编程语言 > 详细

different between c++ and java

时间:2014-02-27 23:16:16      阅读:645      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
Java doesnot support pointers. Pointers are tricky to use and troublesome.

Java does not support multiple inheritances because it causes more problems than it solves. Instead Java supports multiple interface inheritance, which allows an object to inherit many method signatures from different interfaces with the condition that the inheriting object must implement those inherited methods. The multiple interface inheritance also allows an object to behave polymorphically on those methods.

Java does not include structures or unions.

Java does not support destructors but adds a finalize() method. Finalize methods are invoked by the garbage collector prior to reclaiming the memory occupied by the object, which has the finalize() method. This means you do not know when the objects are going to be finalized. Avoid using finalize() method to release non-memory resources like file handles, sockets, database connections etc because Java has only a finite number of these resources and you do not know when the garbage collection is going to kick in to release these resources through the finalize() method.

All the code in Java program is encapsulated within classes therefore Java does not have global variables or functions.

C++ requires explicit memory management, while Java includes automatic garbage collection.
bubuko.com,布布扣

different between c++ and java,布布扣,bubuko.com

different between c++ and java

原文:http://www.cnblogs.com/leetcode/p/3570588.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!