Java
  Home arrow Java arrow Page 4 - Syntactic Comparison of Java and C/C++
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM Rational Software Development Conference
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

Syntactic Comparison of Java and C/C++
By: Barzan "Tony" Antal
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 7
    2007-11-21

    Table of Contents:
  • Syntactic Comparison of Java and C/C++
  • Data Types
  • Pointers
  • Summing Up

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    PCmover - $15 Off with Coupon Code CJPH7Q

    Syntactic Comparison of Java and C/C++ - Summing Up
    (Page 4 of 4 )

    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.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Thanks for taking time to read the first part of this 2-part series. Don't...
       · it was a nice discussion it clearly differentiate the nature of the most powerfull...
       · Thanks for your input regarding my article. I appreciate your willingless to leave a...
       · Specifically, it should be going live tomorrow morning. :)
     

       

    JAVA ARTICLES

    - Introducing the Spring Framework
    - Java Classes
    - Completing the Syntactic Comparison of Java ...
    - Syntactic Comparison of Java and C/C++
    - Java Statements
    - Conditionals, Expressions and Other Java Ope...
    - Java Operators
    - Primitive Data Types and Basic Language Rule...
    - Java and Object-Oriented Programming
    - Java Beginning Programming
    - Gaming Development Setup
    - Using RPC-Style Web Services with J2EE
    - Integrating XML with J2EE
    - Taming Tiger: Concurrent Collections
    - Combating the ‘Object Crisis’

    Iron Speed



    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway