This article introduces you to the Java programming language. The first of two parts, it is excerpted from chapter one of Sams Teach Yourself Java 2 in 21 Days, 4th Edition, written by Rogers Cadenhead and Laura Lemay (Sams; ISBN: 0672326280).
Getting Started with Java - Introduction to Java (Page 2 of 6 )
Java is an object-oriented, platform-neutral, secure language designed to be easier to learn than C++ and harder to misuse than C and C++.
Object-oriented programming(OOP) is a software development methodology in which a program is conceptualized as a group of objects that work together. Objects are created using templates called classes, and they contain data and the statements required to use that data. Java is completely object-oriented, as you'll see later today when you create your first class and use it to create objects.
Platform neutrality is the ability of a program to run without modification in different computing environments. Java programs are compiled into a format called bytecode that is run by any operating system, software, or device with a Java interpreter. You can create a Java program on a Windows XP machine that runs on a Linux Web server, Apple Mac using OS X, and Palm personal digital assistant. As long as a platform has a Java interpreter, it can run the bytecode.
Note - This feature has typically been touted as a way to "write once, run anywhere" by Java admirers, including the authors of this book. However, practical experience with Java shows that there are always some inconsistencies and bugs in the implementation of the language on different platforms. For this reason, a more derisive slogan has been coined among some less-than-admirers: "write once, debug everywhere." Even so, the platform neutrality of Java makes it much easier to develop software that isn't locked into a single operating system or computing environment.
Though the ease of learning one language over another is always a point of contention among programmers, Java was designed to be easier than C++ primarily in the following ways:
Java automatically takes care of memory allocation and deallocation, freeing programmers from this tedious and complex task.
Java doesn't include pointers, a powerful feature of use primarily to experienced programmers that can be easily misused.
Java includes only single inheritance in object-oriented programming.
The lack of pointers and the presence of automatic memory management are two key elements to the security of Java. Another is the way that Java programs running on Web pages are limited to a subset of the language to prevent malicious code from harming a user's computer.
Language features that could easily be employed for harmful purposesósuch as the abilities to write data to a disk and delete filesócannot be executed by a program when it is run by a World Wide Web browser's Java interpreter.
For a longer discussion of Java's history and the strong points of the language, read Appendix A, "Choosing Java."