Java ScreenShot
     

Screenshot Core Java 2: Volume I - Fundamentals

Table of Contents
 1.  An Introduction to Java


Advantages of Java

One obvious advantage is a runtime environment that provides platform independence: you can use the same code on Windows, Solaris, Linux, Macintosh, and so on. This is certainly necessary when programs are downloaded over the Internet to run on a variety of platforms. Another coding advantage is that Java has a syntax similar to that of C++, making it easy for C and C++ programmers to learn. Then again, Visual Basic programmers will probably find the syntax annoying.

Java graphics notes_icon.gif

If you are coming from a language other than C++, some of the terms used in this section will be less familiar—just skip those sections. You will be comfortable with all of these terms by the end of .

Java is also fully object oriented—even more so than C++. Everything in Java, except for a few basic types like numbers, is an object. (Object-oriented coding has replaced earlier structured techniques because it has many advantages for dealing with sophisticated projects. If you are not familiar with Object-oriented programming, s 3 through 6 provide what you need to know.) However, having yet another, somewhat improved, dialect of C++ would not be enough. The key point is this: It is far easier to turn out bug-free code using Java than using C++. Why? The designers of Java thought hard about what makes C++ code so buggy. They added features to Java that eliminate the possibility of creating code with the most common kinds of bugs.
  • The Java designers eliminated manual memory allocation and deallocation.

    Memory in Java is automatically garbage collected. You never have to worry about memory corruption.

  • They introduced true arrays and eliminated pointer arithmetic.

    You never have to worry about overwriting an area of memory because of an off-by-one error when working with a pointer.

  • They eliminated the possibility of confusing an assignment with a test for equality in a conditional statement.

    You cannot even compile if (ntries = 3). . . . (Visual Basic programmers may not see the problem, but, trust us, this is a common source of confusion in C/C++ code.)

  • They eliminated multiple inheritance, replacing it with a new notion of interface that they derived from Objective C.

    Interfaces give you most of what you want from multiple inheritance, without the complexity that comes with managing multiple inheritance hierarchies. (If inheritance is a new concept for you, will explain it.)

Java graphics notes_icon.gif

The Java language specification is public. You can find it on the Web at http://java.oracle.com/docs/books/jls/html/index.html.

Screenshot

Java ScreenShot
     
Top
 

Comments