Link to home
Start Free TrialLog in
Avatar of Axter
AxterFlag for United States of America

asked on

List of Syntax differences between Java and C++

I'm not looking for a pro con type list.
I'm looking for a list of programming syntax differences between Java and C++.

I'm currently reading a Java book, but so much of it is stuff I already know since Java is so similar to C++.

The kind of list I'm looking for is something like the following:
No Constructor initialize list  -> superclass initialize on first line of constructor
Boolean condition statements
Labeled loop-breaks
No pointers ?????
No multiple inheritance

Avatar of bloodredsun
bloodredsun
Flag of Australia image

Avatar of Axter

ASKER

The list you posted are pro con list.

As I stated in my question I'm *NOT* looking for a pro-con list.

I'm looking for a list of programming syntax differences.
Avatar of Axter

ASKER

I'm not looking for std::list object type comparison with java list.

I'm looking for Language **Syntax** differences between Java and C++.

Please look at the examples I posted in my question.
Avatar of guitaristx
guitaristx

Unfortunately, you're just going to have to _learn_ the syntax of Java, and make your own comparisons.  The synaxes (sp?) between the two languages, as you've already stated, are very similar; HOWEVER, in order to understand fully the syntax of Java, you must understand the semantics behind the syntax.  For instance, the "package" keyword.  Inside a Java class, the "package" keyword indicates that the class belongs to the class specified by the string immediately following the keyword.  There is no *true* syntactic equivalent in C++.  It's just a matter of the two languages being different.  Rather than trying to learn Java in the way that you're doing:
"Java is C++ with the following differences: ..."
You should learn Java and treat it as its own language, its own syntax, semantics, everything.  Learn the Java programming paradigm, just as you've learned (one of) the C++ programming paradigm(s), and it will serve you well.  Otherwise, you'll be wrestling with Java in an attempt to fit it into a C++ - shaped box.  As the quote says, "One can write FORTRAN code in any language."

As far as your original question, you might, rather than expecting someone to give you a list, try observing a difference between the two languages, and then bring the question to EE like this:
"I'm learning Java, and trying to understand X.  I know how X works in C++.  How does it work in Java?"
And you'll probably obtain answers that are much more useful to you.
Avatar of Axter

ASKER

guitaristx,

I'm sorry, but I know what works for me.
I've been programming for over 15 years, and I know what's the best methods that works for me, and what will not work.

Reading a Java book that mostly has the same information that I've learned in C++ will just bore me to death, and I will find it hard to finish it.

I do better at learning languages by reference, then I do by reading a book cover-to-cover.

So my question still stands as-is.

If no-one can provide the link, I'll request a deletion of this question.

I'm just looking for the syntax differences, and I'm not really concern with the details.
I'm just looking for something I can use as a reference, and perhaps add my on notes to it.
ASKER CERTIFIED SOLUTION
Avatar of Javatm
Javatm
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Axter

ASKER

>>http://www.horstmann.com/ccj2/ccjapp3.html

That link comes close to what I'm looking for, but it's going in the wrong direction. (Moving from Java to C++)

I'm moving from C++ to Java.

If no one comes up with a better link, I'll award you the points.
>>I'm sorry, but I know what works for me.
>>I've been programming for over 15 years, and I know what's the best methods that works for me, and what will not work.

And I know people with similar attitudes, whose Java code I've been forced to maintain.  Their Java is written in C++, because they considered Java to be a "sort of like C++" language, and tailored their code to be as C++ - like as possible.  This is a Bad Thing.  If you're not into reading a book or tutorial, I'd recommend reading the language specification:
http://java.sun.com/docs/books/jls/second_edition/html/j.title.doc.html
Avatar of Axter

ASKER

>>Their Java is written in C++, because they considered Java to be a "sort of like C++" language, and tailored their code to
>>be as C++ - like as possible.

I expect that I will be making similar mistakes.  I would expect that even if I did read a Java book cover-to-cover.

I've seen plenty of C programmers that have taken C++ courses and read C++ books, but still produce C style C++ programs.

It's not as easy as you think moving from one paradigm to another.
The trick is learning to *continue* to progress to the new paradigm as you go, and not expect it to happen over night.
> That link comes close to what I'm looking for, but it's going in the wrong direction. (Moving from Java to C++)

I had a hard time looking for the Java to C++ convertion but I think the link is still informative you just do it in reverse.
Just a question, why do you plan to move to C++ ?

It would be better to maybe check C#, since the paradigm goes to C > C++ > Java > C#.
Here's another one that I found usefull :
http://www.macadamian.com/codingconventions.htm
Avatar of Axter

ASKER

>>I had a hard time looking for the Java to C++ convertion but I think the link is still informative you just do it in reverse.
>>Just a question, why do you plan to move to C++ ?

I think you misunderstood me.
I'm not moving to C++.  I'm moving to Java.

I'm currently a C++ expert, and I'm ranked in top three in the C++ Topic area.

I now want my Java skills to be equal to my C++ skills.
Oh now I see, sorry for the confusion I was actually having a problem on my own quetion in a seperate thread :)

Java API (jdk 1.5) :
http://java.sun.com/j2se/1.5.0/docs/api/

From C/C++ to Java :
http://www.eteks.com/ctojava.html

Good Online Guide :
http://javaalamanac.com
http://java.sun.com/learning/new2java/index.html

Hope that helps . . .
Javatm

Avatar of Axter

ASKER

I found a link in the java sun site that had some really good information on this topic (C++ <> Java)

http://java.sun.com/docs/white/langenv/Simple.doc2.html

It's a White Paper that not only describes some of the differences, but also includes the motivation behind the change.