48 Part I: Getting Started The word Sam (Web hosting account)

48 Part I: Getting Started The word Sam is like a Java identifier because Sam is a name for a particular person. Words like Sam, Dinswald, and McGillimaroo don t come prepacked with meaning in the English language. These words apply to different people depending on the context and become names when parents pick one for their newborn kid. Now consider the sentence Julius Caesar is a person. If you utter this sentence, you re probably talking about the fellow who ruled Rome until the Ides of March. Although the name Julius Caesar isn t hard-wired into the English language, almost everyone uses the name to refer to the same person. If English were a programming language, the name Julius Caesar would be an API identifier. So here s how I, in my own mind, divide the words in a Java program into categories: Keywords: A keyword is a word that has its own special meaning in the Java programming language, and that meaning doesn t change from one program to another. Examples of keywords in Java include if, else, and do. The Cheat Sheet in the front of this book has a complete list of Java keywords. The JCP committee members, who have the final say on what constitutes a Java program, have chosen all Java s keywords. If you think about the two parts of Java, which I discuss in The grammar and the common names section earlier in this chapter, the Java keywords belong solidly to the Language Specification. Identifiers: An identifier is a name for something. The identifier s meaning can change from one program to another, but some identifiers meanings tend to change more than others. Identifiers created by you and me: As a Java programmer (yes, even as a novice Java programmer), you create new names for classes and other things that you describe in your programs. Of course, you may name something Prime, and the guy writing code two cubicles down the hall can name something else Prime. That s okay because Java doesn t have a predetermined meaning for the word Prime. In your program, you can make Primestand for the Federal Reserve s prime rate. And the guy down the hall can make Primestand for the bread, roll, preserves, and prime rib. A conflict doesn t arise, because you and your co-worker are writing two different Java programs. Identifiers from the API: The JCP members have created names for many things and thrown at least 3,000 of these names into the Java API. The API comes with each version of Java, so these names are available to anyone who writes a Java program. Examples of such names are String, Integer, JWindow, JButton, JTextField, and File.
Need a managed web hosting provider to help maintain your website? Our web hosting service is the preferred choice of thousands of demanding customers.

Leave a Reply