| | |
begginer
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
•
•
I Used to be a c++ programmer and now i'm starting to learn java all by my self so i need a help in how to get starting begging with compiler and IDE tools and the basic diffrants between c++ and java
Thanks
NetBeans 6.1 (or higher)
--there are others (I think JUnit is one) but this is a very good one that will help you familiarize yourself with the language easily.
A Note about Java vs C++.
The biggest differences are--
Java has "reference-variables" that act as references AND pointers.
Java's Erasure types (Generics) are not as lenient as C++'s Templates.
Java has incredibly extensive libraries. Learning the syntax is easy, but learning the variety of API's can take you quite some time.
In Java, you pass by reference, not value. Also no method that returns a reference can be treated as an lvalue.
There is no misdirection operator in Java. You use the dot (. ) operator for member-access in all scenarios. For example--
// C++ style
c++ Syntax (Toggle Plain Text)
int p[] = {1, 3, 2, 4}, size = 4; //assuming Sort is a class and Merge is an inner class Sort::Merge *merge = new Sort::Merge; // :: member access for inner class Merge merge->mergeSort(p, 0, size - 1); // -> misdirection for method mergeSort in inner class Merge
// Java style
java Syntax (Toggle Plain Text)
int p[] = {1, 3, 2, 4}; Sort s = new Sort(); // paranethesis always required when instantiating an object, even if // the object has no other defined Constructor Sort.Merge merge = s.new Merge(); // pointers/references not declared differently // dot operator instead of :: // Reference-qualifier needed for inner class construct // Java only uses heap, no stack so all new objects // are declared new for references/pointers merge.mergeSort(p, 0, p.length - 1); // . operator used for java "pointers"
There are more differences, but these should help you get started with understanding the differences.
Oh by the way, Java's generics are a bit more restrictive than Templates. You cant use primitive types (even if they are constant integral types) for Generics. You can only use Objects.
If you have the absolute need to declare a constant pointer, or a solid reference to a particular address and still want to be able to change the value, you can use the final modifier.
Be warned that also, Java has no real const (read-only) modifier, as opposed to C/C++.
Last edited by Alex Edwards; Jul 22nd, 2008 at 4:18 am.
![]() |
Similar Threads
- Begginer: JSP Cascading Comb box. (JSP)
- Arrays Assignment!!! (C++)
- Help with input (C)
- Help complete typical question with for loops (C++)
- x and y check desk geomatary (*nix Hardware Configuration)
- i need ur help (C++)
- data access (Visual Basic 4 / 5 / 6)
- Canvas and shape problem (C++)
Other Threads in the Java Forum
- Previous Thread: quick java question(chars)
- Next Thread: Chatting Program - Throws IO Exception
| Thread Tools | Search this Thread |
-xlint actionlistener android api applet application array arrays automation binary blackberry block bluetooth character chat class classes client code component consumer database desktop developmenthelp draw eclipse error event exception fractal ftp game givemetehcodez graphics gui html ide image input integer j2me j2seprojects java javac javaee javaprojects jmf jni jpanel julia lego linked linux list loop loops mac map method methods mobile netbeans newbie notdisplaying number online oracle page print printf problem program programming project properties recursion researchinmotion rotatetext rsa scanner screen server set singleton size sms sort sql string swing template textfields threads time title tree tutorial-sample update windows working





