Java 7 for Absolute Beginners
CHAPTER 2 ■ JAVA SYNTAX The first custom is that each class name should start with a capital letter. Second, each logical word ...
CHAPTER 2 ■ JAVA SYNTAX On a field, the static keyword has a similar effect as it does on a method: A static field has one insta ...
CHAPTER 2 ■ JAVA SYNTAX Listing 2-10. Methods // a classic getter method @Override public int[] getInts() { return ints; } // a ...
CHAPTER 2 ■ JAVA SYNTAX ■ Warning Static methods can cause problems. Suppose you have two threads, each of which is working with ...
CHAPTER 2 ■ JAVA SYNTAX Access Modifiers Classes, interfaces, fields, and methods all use various access modifiers to indicate w ...
CHAPTER 2 ■ JAVA SYNTAX interfaces, that means a class that implements the interface must implement the methods defined in the i ...
CHAPTER 2 ■ JAVA SYNTAX Listing 2-14. Handling an exception try { averageImpl.setInts(ints2); } catch(IllegalArgumentException i ...
CHAPTER 2 ■ JAVA SYNTAX know immediately when we need to catch checked exceptions. Runtime exceptions (as the name implies) can ...
CHAPTER 2 ■ JAVA SYNTAX public StaticBlockClass(int identifier) { whichOne = Integer.toString(identifier); } public StaticBlockC ...
CHAPTER 2 ■ JAVA SYNTAX Listing 2-19. Bad style in a multi-line block comment int counter /* Please don't do this */ = 0; By con ...
CHAPTER 2 ■ JAVA SYNTAX Listing 2-21. A Javadoc comment for a method /** * This method makes a Cat object chase the given Mouse ...
C H A P T E R 3 35 Data Types Most programming languages have data types. Java has several data types. The first characteristic ...
CHAPTER 3 ■ DATA TYPES Table 3-1. Integer primitives Type Bits Minimum Value Maximum Value byte 8 -128 127 short 16 -32768 32767 ...
CHAPTER 3 ■ DATA TYPES boolean The boolean data type indicates whether something is true or false. In fact, those two words (tru ...
CHAPTER 3 ■ DATA TYPES Listing 3-1. String examples String myString = "my string"; String yourString = "your string"; String our ...
CHAPTER 3 ■ DATA TYPES ■ Note Declaring a float literal requires appending f to the end of the literal. Otherwise, the compiler ...
CHAPTER 3 ■ DATA TYPES // which will produce this: ' is my favorite character // (my actual favorite character is ;) // And now ...
CHAPTER 3 ■ DATA TYPES Listing 3-4. String with escape sequence String errorMessage = "The whatsit didn't work!\nCheck the doohi ...
CHAPTER 3 ■ DATA TYPES Listing 3-6. Integer example // declare an int int myInt = 1; // and a String that contains a number Stri ...
CHAPTER 3 ■ DATA TYPES lang/Boolean.html and the JavaDoc for the Character class at http://download.oracle.com/javase/7/ docs/ap ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf