What Is Java, and Why Is It So Great?

Java is a programming language in the tradition of C and C++. As a result, if you have any experience with C or C++, you'll find yourself in familiar territory often as you learn the various features of Java.



However, Java differs from other programming languages in a couple of significant ways. The following sections describe the most important differences.



Platform independence


One of the main reasons Java is so popular is its platform independence, which means that Java programs can be run on many different types of computers. A Java program runs on any computer with a Java Runtime Environment, also known as a JRE, installed. A JRE is available for almost every type of computer — PCs running Windows, Macintosh computers, Unix or Linux computers, huge mainframe computers, and even cell phones.



Object orientation


Java is inherently object-oriented, which means that Java programs are made up of programming elements called objects. Simply put, an object is a programming entity that represents either some real-world object or an abstract concept.



All objects have two basic characteristics:



  • Objects have data, also known as state. For example, an object that represents a book has data such as the book's title, author, and publisher.

  • Objects also have behavior, which means that they can perform certain tasks. In Java, these tasks are called methods. For example, an object that represents a car might have methods such as start, stop, drive, or crash. Some methods simply allow you to access the object's data. For example, a book object might have a getTitle method that tells you the book's title.

Classes are closely related to objects. A class is the program code you write to create objects. The class describes the data and methods that define the object's state and behavior. Then, when the program executes, classes are used to create objects.



For example, suppose you're writing a payroll program. This program needs objects to represent the company's employees. So, the program includes a class (probably named Employee) that defines the data and methods for each Employee object. Then, when your program runs, it uses this class to create an object for each of your company's employees.



The Java API


The Java language itself is very simple. However, Java comes with a library of classes that provide commonly used utility functions that most Java programs can't do without. This class library, called the Java API, is as much a part of Java as the language itself. In fact, the real challenge of learning how to use Java isn't learning the language; it's learning the API. The Java language has only 50 keywords, but the Java API has several thousand classes — with tens of thousands of methods you can use in your programs.



You don't have to learn anywhere near all of the Java API. Most programmers are fluent with only a small portion of it. If you need to use some class from the API that you aren't yet familiar with, you can look up what the class does in the Java API documentation.










dummies

Source:http://www.dummies.com/how-to/content/what-is-java-and-why-is-it-so-great.navId-323185.html

No comments:

Post a Comment