Home arrow Java & J2EE arrow Page 4 - Syntactic Comparison of Java and C/C++

Summing Up - Java

Nowadays millions of computer programmers want to become multi-lingual; for that reason they try to acquire understanding of multiple programming languages. Experienced coders know that it is possible to get the hang of a new language in a fairly short amount of time. Being able to compare the syntax of different languages makes learning new ones easier.

TABLE OF CONTENTS:
  1. Syntactic Comparison of Java and C/C++
  2. Data Types
  3. Pointers
  4. Summing Up
By: Barzan "Tony" Antal
Rating: starstarstarstarstar / 14
November 21, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Now is the perfect time to sum up what we’ve just learned. First of all, Java as a programming language was consciously simplified and the most common sources of trouble were eliminated, either completely or by incorporating specific safer workarounds.

You can add comments the same way in both languages, either the // per line or the /* */ for multiple lines. These are called implementation-comments and they’re derived from C/C++. However, Java has document-comments too. You can delimit these using /** */ tags. Additionally, these can be exported to HTML using javadoc.

Using operators = and == in Java considers only the references. If the coder wants to either copy or test the equality of two objects/arrays s/he should use clone() and equals(), respectively. A null in Java is not akin to 0 per se, it stands for a void reference.

C-like pointers do not exist in Java. They are created as references and de-referenced automatically. Some might argue that Java has some kind of pointers; well it has, but they are not true pointers from a C/C++ point of view — there is no pointer arithmetic at all.

The idea of restrict programmers from directly manipulating addresses of the memory was mostly carried out to enhance the security of the language. Yes, one of the reasons is to provide more of a type-safe coding. But the most important underlying reason is that it gives less control over the system’s resources to programmers. Thus it drastically decreases the opportunities to code malicious programs (e.g., buffer and/or stack overflow, etc.).

The last syntactic difference between Java and C I want to point out before I finish this half of the two-part series is about global data and variables. In Java there are no structs or unions. Everything is part of a class. Static methods behave like globals inside a class.

Until next time, keep coding! Stick around; you won’t want to miss the next part.



 
 
>>> More Java & J2EE Articles          >>> More By Barzan "Tony" Antal
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

JAVA & J2EE ARTICLES

- More Java Bugs Lead to More Attacks
- Oracle's Java One Brings News, Surprises
- Oracle Patches Java Runtime Environment
- Apple Syncs Java Update with Oracle
- Spring 3.1 Java Development Framework Compat...
- Jelastic Java PaaS Availability and Pricing ...
- NetBeans 7.1 Released, Supports JavaFX 2
- SolarWinds Releases Newest Version of Java M...
- Free Monitoring Tool for Java Apps on Heroku
- Heroku Adds JCloud Platform Support, Java 7 ...
- Java SE 8 Speculation in Full Swing
- Java SE 7 Now Available
- New JVM Language and Java Reporting Tool
- Java 7 Release Update and New Eclipse Toolkit
- The Best Java Netbeans IDE Plugins

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: