Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML
 
 
Hot Web Programming Job

 

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML

[an error occurred while processing this directive]

Java Notes

For C++ programmers

[an error occurred while processing this directive]

Java inherited many features from C++, but some of the important differences are mentioned below.

  1. Case. Class names always start with an upper case character, Methods (called functions in C++) start with a lower case character.
  2. File names, directories. Source file names must be exactly the same name (including case) as the class, with the extension ".java". Generated object file names will have the class name followed by ".class". Many class files can be compressed into a "Java archive" with the file extension ".jar". A package is a way to group classes together and corresponds to a directory in the file system. There are no header (.h) files in Java.
  3. No header files. import is the rough equivalent of C++'s #include, but it doesn't include source code - it simply tells which .class/.jar files can be searched for symbol definitions.
  4. .class and JIT. The .class files represent Java programs in a machine independent way (called Java Byte Code for the Java Virtual Machine) that is mostly, but not quite, specific machine object code. When you run a Java program a Just In Time (JIT) compiler translates the Java Byte Code to machine instructions for your CPU. This accounts for the annoying delay when starting Java programs.
  5. No preprocessor. There are no #defines, typedefs, conditional compilation, etc.
  6. Everything in classes. All functions (called methods in Java) and variables must be defined in some class. There are no structs or unions. Java uses the superior idea of "interface" in place of multiple inheritance.
  7. References, not pointers. Java has references, which are pointers, but the name change is intended to show that you can't use them as C++ pointers. There are no address of(&), dereference(*), or arithmetic operators - these operations are basically automatic.
  8. Only primitives and references. Variables can contain only primitive values (long, int, short, byte, char, float, double, boolean) or object references. Variable do not contain object values. The biggest possible variable is therefore only 8-bytes (long). All arrays, strings, and other objects must be dynamically allocated on the heap.
  9. No bad references. It's impossible to reference uninitialized memory (altho references can be null).
  10. Garbage collection. There is no delete to deallocate objects. When there is no longer a reference to an object, it is eligible for automatic garbage collection when memory is needed. This is one of the most wonderfully profound improvements Java made over C++.
  11. Unicode. Type char is two bytes containing a Unicode character: first 128 characters same as ASCII, first 256 same as ISO 8859-1 (Latin-1), remainder encode basically all modern human scripts.
  12. boolean is the only type that can be used where conditional expressions are expected (eg, in an if statement). No more zero vs non-zero tests.
  13. String. You can't modify a String, only create a new one. Use StringBuilder or StringBuffer for something that changes.
  14. No operator overloading. All operations in classes are implemented as methods. This can make data structure operations look a little awkward.
  15. Data structures. Java's Collections libraries correspond approximately to what's in C++'s Standard Template Library (STL). Java 5 introduced generics, which are similar to C++ templates. The biggest shock is that Java's data structure libraries only deal with object types, not primitives. Java's ArrayList<T> is about the same as C++'s Vector<T>.
  16. Libraries. The Java libraries are astounding more extensive than the standard C++ libraries. They predefine over 3,000 classes you can use.

References

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

1 comments so far (
post your own) View All Comments Latest 10 Comments:

i want learn c++, i have many deficulties in programing plz help me

Posted by ali on Saturday, 04.11.09 @ 14:59pm | #86730

      View This Comment Separately
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2007. All rights reserved.