Java 7 for Absolute Beginners
CHAPTER 3 ■ DATA TYPES Java provides a convenience class for arrays. The Arrays class consists of many static methods to do hand ...
CHAPTER 3 ■ DATA TYPES if (numberOfAdjacentMines == 1) { mineIcon = new MineIcon(1); } else if (numberOfAdjacentMines == 2) { mi ...
CHAPTER 3 ■ DATA TYPES ■ Caution Do not write collections of constants this way. They can be compared to int values, and that's ...
CHAPTER 3 ■ DATA TYPES Listing 3-15. findCardinalDirection method public static Direction findCardinalDirection (int degrees) { ...
CHAPTER 3 ■ DATA TYPES } else { return NORTH; } } } Now that we have our completed enumeration, we need a test program to see ho ...
CHAPTER 3 ■ DATA TYPES How arrays work What a null is and how to use one to good effect How to create and use enumerations We ...
C H A P T E R 4 51 Operators Java includes many operators, from ordinary mathematical operators such as a minus sign (-) to oper ...
CHAPTER 4 ■ OPERATORS Continued Category Operators logical OR || ternary? : assignment = += -= *= /= %= &= ^= |= <<= & ...
CHAPTER 4 ■ OPERATORS The fifth line prints 1 because we use integer literals (as we covered in the previous chapter). Consequen ...
CHAPTER 4 ■ OPERATORS Table 4-2. Unary operators Operator Name Description ++expr Prefix increment Adds 1 to the value of the ex ...
CHAPTER 4 ■ OPERATORS The bitwise complement operator promotes the values of byte, short, and char variables to 32 bits before a ...
CHAPTER 4 ■ OPERATORS In the second example, casting an int to a short, we must have a cast operator, to tell the compiler that ...
CHAPTER 4 ■ OPERATORS Multiplicative Operators Java has three multiplicative operators: multiplication (*), division (/), and mo ...
CHAPTER 4 ■ OPERATORS context is textual, it performs concatenation operations. Listing 4-8 demonstrates what happens when the J ...
CHAPTER 4 ■ OPERATORS System.out.println("b as binary: " + Integer.toBinaryString(b)); String leftShiftString = Integer.toBinary ...
CHAPTER 4 ■ OPERATORS Using a shift operator on byte, char, or short values promotes those values to int values. Unary numeric ...
CHAPTER 4 ■ OPERATORS Listing 4-12 illustrates the comparison of primitives Listing 4-12. Comparing primitives int a = 0; float ...
CHAPTER 4 ■ OPERATORS Both print statements print “true” in the console. After all, a student is a person. The nature of object- ...
CHAPTER 4 ■ OPERATORS Listing 4-15. Equality operator examples int a = 0; int b = 1; String s = "s"; String sToo = "s"; System.o ...
CHAPTER 4 ■ OPERATORS Listing 4-18. Bitwise Exclusive OR operator (^) Byte byte1 = Byte.parseByte("01010101", 2); // byte1 = 85 ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf