Chapter 3: Using the Basic Building Blocks 51 (Java web server)

Chapter 3: Using the Basic Building Blocks 51 The Java class Because Java is an object-oriented programming language, your primary goal is to describe classes and objects. (If you re not convinced about this, read the sections on object-oriented programming in Chapter 1.) On those special days when I m feeling sentimental, I tell people that Java is more pure in its object-orientation than most other so-called object-oriented languages. I say this because, in Java, you can t do anything until you ve created a class of some kind. It s like being on Jeopardy!; hearing Alex Trebec say, Let s go to a commercial; and then interrupting him by saying, I m sorry, Alex. You can t issue an instruction without putting your instruction inside a class. In Java, the entire program is a class. I wrote the program, so I get to make up a name for my new class. I chose the name Displayer, because the program displays a line of text on the computer screen. That s why the code in Listing 3-1 starts with class Displayer. (See Figure 3-2.) The entire program class Displayer { public static void main(String args[]) { System.out.println(”You’ll love Java!”); } } Figure 3-2: A Java program is The class Displayer a class. The first word in Listing 3-1, the word class, is a Java keyword. (See the section The words in a Java program, earlier in this chapter.) No matter who writes a Java program, the word classis always used the same way. On the other hand, the word Displayerin Listing 3-1 is an identifier. I made up the word Displayerwhile I was writing this chapter. The word Displayeris the name of a particular class the class that I m creating by writing this program. The Java programming language is case-sensitive. This means that if you change a lowercase letter in a word to an uppercase letter, you change the word s meaning. Changing case can make the entire word go from being meaningful to being meaningless. In the first line of Listing 3-1, you can t replace classwith Class. If you do, the whole program stops working.
We provides quality the CPanel Web Hosting. All our web hosting plans regular, business and expert are competitively priced and unsurpassed in reliability, uptime, and quality of service.

Leave a Reply