The main difference between Java & C++(转载)

转载自:http://stackoverflow.com/questions/9192309/the-main-difference-between-java-c

  1. C++ supports pointers whereas Java does not pointers. But when
    many programmers questioned how you can work without pointers, the
    promoters began saying "Restricted pointers.” So we can say java
    supports Restricted pointers.
  2. At compilation time Java Source code converts into byte code .The
    interpreter execute this byte code at run time and gives output. Java
    is interpreted for the most part and hence platform independent (Write
    once, run anywhere). C++ run and compile using compiler which converts
    source code into machine level languages so c++ is platform dependent
    (Write once, compile anywhere).
  3. Java is platform independent language but c++ is dependent upon
    operating system machine etc. C++ source can be platform independent
    (and can work on a lot more, especially embedded, platforms), although
    the generated objects are generally platform dependent but there is
    clang for llvm which doesn‘t have this restriction.
  4. Java uses both a compiler and interpreter, while C++ only uses a compiler
  5. C++ supports operator overloading multiple inheritance but java does not.
  6. C++ is nearer to hardware then Java
  7. Everything (except fundamental types) is an object in Java (Single root hierarchy as everything gets derived from java.lang.Object).
  8. Java does is similar to C++ but it doesn‘t have the complicated
    aspects of C++, such as pointers, templates, unions, operator
    overloading, structures, etc. Java also does not support conditional
    compilation (#ifdef/#ifndef type).
  9. Thread support is built into Java but not in C++. C++11, the most
    recent iteration of the C++ programming language, does have Thread
    support though.
  10. Internet support is built into Java, but not in C++. On the other
    hand, C++ has support for socket programming which can be used.
  11. Java does not support header files and library files. Java uses import to include different classes and methods.
  12. Java does not support default arguments.
  13. There is no scope resolution operator :: in Java. It has . using which we can qualify classes with the namespace they came from.
  14. There is no goto statement in Java.
  15. Because of the lack of destructors in Java, exception and auto garbage collector handling is different than C++.
  16. Java has method overloading, but no operator overloading unlike C++.
  17. The String class does use the + and += operators to concatenate strings and String expressions use automatic type conversion,
  18. Java is pass-by-value.
  19. Java does not support unsigned integers.

以下转载自:http://geeksquiz.com/c-features-missing-java/

Following features of C++ are not there in Java.

No pointers
No sizeof operator
No scope resolution operator
Local variables in functions cannot be static
No Multiple Inheritance
No Operator Overloading
No preprocessor and macros
No user suggested inline functions
No goto
No default arguments
No unsigned int in Java
No -> operator in java
No stack allocated objects in java
No delete operator in java due to java’s garbage collection
No destructor in java
No typedef in java
No global variables, no global function because java is pure OO.
No friend functions
No friend classes
No templates in java

时间: 2024-07-31 03:10:10

The main difference between Java & C++(转载)的相关文章

ubuntu java version(转载)

Ubuntu/Debian中的update-alternative用来对系统中不同版本的同个软件进行管理.比如,系统中可能装有GNU的Java编译器,和SUN的Java编译器.可以用update-alternatives来设置当前使用它们中的哪一个. 它的原理是在/usr/bin中建立一个link,指向/etc/alternatives中的一个文件,而些文件又是一个link,指向当前使用的命令.比如java命令,查看如下: $ which java/usr/bin/java$ ls -l /us

Debian安装JAVA环境(转载)

Debian官方没有维护专门的Java软件包,所以不能直接用apt-get工具来安装.在Debian系统中要安装Java,有两种方式,一种是用传统方式:一种是Debian方式. 1. 传统方式 在 sun 下载了最新的 JDK,我下载的是 jdk-6u13-linux-i586.bin 并把该文件的属性改成可执行,直接执行该文件 # chmod +x jdk-6u13-linux-i586.bin # ./jdk-6u13-linux-i586.bin 程序运行后会当前目录下生成一个名为 jdk

详细分析Java中断机制-转载

1. 引言 当我们点击某个杀毒软件的取消按钮来停止查杀病毒时,当我们在控制台敲入quit命令以结束某个后台服务时……都需要通过一个线程去取消另一个线程正在执行的任务.Java没有提供一种安全直接的方法来停止某个线程,但是Java提供了中断机制. 如果对Java中断没有一个全面的了解,可能会误以为被中断的线程将立马退出运行,但事实并非如此.中断机制是如何工作的?捕获或检测到中断后,是抛出InterruptedException还是重设中断状态以及在方法中吞掉中断状态会有什么后果?Thread.st

完整全面的Java资源库-----转载

构建 这里搜集了用来构建应用程序的工具. Apache Maven:Maven使用声明进行构建并进行依赖管理,偏向于使用约定而不是配置进行构建.Maven优于Apache Ant.后者采用了一种过程化的方式进行配置,所以维护起来相当困难. Gradle:Gradle采用增量构建.Gradle通过Groovy编程而不是传统的XML声明进行配置.Gradle可以很好地配合Maven进行依赖管理,并且把Ant脚本当作头等公民. 字节码操作 编程操作java字节码的函数库. ASM:通用底层字节码操作及

SoapUI API + Groovy API + Difference with Java

用soapUI进行webservice测试过程中,必不可少的要用到soapUI封装的代码.我们一起学习吧:) SoapUI 5.1.2 API:http://www.soapui.org/apidocs/index.html SoapUI中我们经常会用到Groovy script,想不起来groovy的某个方法时,就去它的类库找找吧:) Groovy API: http://groovy-lang.org/api.html Groovy的语法是怎样的?它跟Java语法有什么不同?去里面瞅瞅吧:)

java匿名内部类 (转载)

匿名内部类也就是没有名字的内部类 正因为没有名字,所以匿名内部类只能使用一次,它通常用来简化代码编写 但使用匿名内部类还有个前提条件:必须继承一个父类或实现一个接口 实例1:不使用匿名内部类来实现抽象方法 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 abstract class Person {     public abstract void eat(); } class Child extends Person {     public void eat()

The difference between java application library and java web lib

I remebered that i had writed a java web programming.At that time, i added jar packages by "build path" so that i could import a user library path at firstly. When the path of jar library had been imported into eclipse,to complise program was ri

LeetCode算法题-Find the Difference(Java实现-五种解法)

这是悦乐书的第214次更新,第227篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第82题(顺位题号是389).给定两个字符串s和t,它们只包含小写字母.字符串t由随机混洗字符串s生成,然后在随机位置再添加一个字母.找到t中添加的字母.例如: 输入:s ="abcd", t ="abcde" 输出:'e' 说明:'e'是添加的字母. 本次解题使用的开发工具是eclipse,jdk使用的版本是1.8,环境是win7 64位系统,使用Jav

没有main方法的java程序

public  Class TestDemo { static{ System.out.println("Hello World!"); System.exit(0); } } 运行一下试试吧!