2.Java完全对象化,比如数组在Java中是一个对象,含有length这个属性;而不像C++中数组是一个指针。1.Java 里 int char ... 这些是什么
2.数组不是指针。
3.非成员 std::size 获取编译期可确定的数组长度,动态的用 std::vector。
同时因为Java中所有类都会继承Object这个基类,所以可以把几个好不相干的类用基类联系起来,比如放在同一个数组里。Boost.Any/void*
3.Java中没有指针这样不安全(虽然指针速度快)的概念。没有这个东西咋还成优势了?按这理论 C# 有 unsafe 反而还落后 Java 一截了。
4.Java中有完善的内存管理机制,能自动垃圾回收,最大可能降低内存溢出的可能,同时提高编程效率。1.成也垃圾回收,败也垃圾回收
2.垃圾回收还能降低内存溢出么
3.std::vector std::unique_ptr std::shared_ptr/weak_ptr。够了。顺便问一下:
4.
Java has been criticized for not supporting arrays of more than 231−1 (about 2.1 billion) elements.
This is a limitation of the language; the Java Language Specification, Section 10.4, states that:
Arrays must be indexed by int values... An attempt to access an array component with a long index value results in a compile-time error.
Supporting large arrays would also require changes to the JVM. This limitation manifests itself in areas such as collections being limited to 2 billion elements[20] and the inability to memory map files larger than 2 GB.[21] Java also lacks true multidimensional arrays (contiguously allocated single blocks of memory accessed by a single indirection), which limits performance for scientific and technical computing.12]
这内存管理也不完善啊?!5.Java中有完善的异常机制(标准C++中不够完善)。
强制处理异常,很“完善”。7.Java标准库完整的多,相比之下C++除了一个STL(而且还超级难用)就没了,实际C++编程中需要大量使用第3方库。
1.Java的不难用么。。。
2.Java 不用第三方库?那某楼鼓吹 Java 开发效率的要被打脸了。8. Java因为是把程序编译为字节码,运行时需要JVM把字节码再翻译为机器码,所以他跨平台,一次编译到处运行。
到处调试。9.Java原生支持多线程。
C++ 11 也原生支持。