0

Difference between java and c++??

8th Feb 2017, 6:22 PM
Joshi Chand
Joshi Chand - avatar
3 odpowiedzi
+ 2
After a google search: The most important difference is that Java is a memory-safe language, whereas C++ is not. This means that errors in Java programs are detected in defined ways—for example, attempting a bad cast or indexing an array out of bounds results in an exception. Similar errors in C++ lead to undefined behavior, where instead of raising an exception or crashing, your program might keep running and crash later or even give the wrong answer or behavior. Overall, the presence of unsafe features in C++ such as unchecked casts, pointer arithmetic, and manual memory management (delete) means that C++ programming is much more error-prone that Java programming.
8th Feb 2017, 6:25 PM
Felipe
Felipe - avatar
+ 2
According to Felipe and Zilvinas: Yes, Java gives us a garbage collector and is platform independent 😎 AND pointers imo are more comfy to use.
8th Feb 2017, 9:59 PM
Tashi N
Tashi N - avatar
+ 1
I would say the biggest difference is how programs are executed. Java is platform-independent and runs on virtual machine, in contrast with C++ which is compiled to a specific system machine code.
8th Feb 2017, 7:47 PM
Zilvinas Steckevicius
Zilvinas Steckevicius - avatar