Presentation is loading. Please wait.

Presentation is loading. Please wait.

Session 1 CS-240 Data Structures Binghamton University Dick Steflik.

Similar presentations


Presentation on theme: "Session 1 CS-240 Data Structures Binghamton University Dick Steflik."— Presentation transcript:

1 Session 1 CS-240 Data Structures Binghamton University Dick Steflik

2 “Java is C++ without the knives, clubs and guns”

3 Java vs. C++ ● Java – run-time platform independence ● only needs to be compiled once – makes deployment easier (one set of binaries) ● each platform requires a unique JVM ● different versions (SE, EE, ME) ● C++ – source levelplatform independence (sometimes) ● needs to be recompiled for each platform – compiled code is platform native code – needs platform specific install procedure – nothing like jvm required (unless using MS.Net)

4 Java vs. C++ ● Java – Automatic garbage collection ● objects are created via class constructors (new) ● objects are deleted as soon as they go out of scope ● C++ – garbage collection is manual ● objects are created via class constructors(new ) ● delete returns storage to storage management – destructor run automatically when object goes out of scope ● susceptible to memory leaks

5 Java vs. C++ ● Java – Primitives ● boolean ● int ● double ● byte ● float (IEEE) ● char (unicode) – Structured ● arrays ● vectors ● stacks ● queues ● C++ – Primitives ● bool ● byte ● short ● long ● double ● unsigned ● char (signed byte) – Structured ● arrays ● struct ● union ● enum

6 Java vs. C++ ● Arrays – 0 based – accessed via indexing operator [ ] – bounds checking automatically done ● no buffer overflows ● Arrays – 0 based – accesed via indexing operator [] or by pointer dereferencing – bounds checking only done by compiler option, normally not done ● buffer overflows

7 Java vs. C++ ● Object references – can be passed in a method call – created at instantiation ● Pointers to objects – pointers are a primitive data type ● can be manipulated via arithmetic ops ● can be used in predicate formation ● can be referenced and dereferenced

8 Java vs. C++ ● no operator overloading ● method overloading – unique signatures ● operator overloading – define new definitions (within a class for what an operator does ● function overloading – unique signatures

9 Java vs. C++ ● import – which core packages to use – compiled class files stay small ● #include – which source level packages to include in the file to be compiled – source (as seen by compiler) grows quite large – object files stay small – application must be linked via the system linker

10 Java vs. C++ ● Strings are a built-in class ● strings are null terminated arrays of chars – STL has string class


Download ppt "Session 1 CS-240 Data Structures Binghamton University Dick Steflik."

Similar presentations


Ads by Google