摘要:
1 package chapter8对象和类; 2 3 public class Circle2 { 4 double radius; 5 static int numberOfObjects = 0; 6 7 Circle2() { 8 radius = 1.0; 9 numberOfObjects++;10 }11 12 Circle2(double newRadius) {13 radius = newRadius;14 numberOfObjects++;15 }16 ... 阅读全文
摘要:
Chapter 7 Multidimensional Arrays1 int[][] m = new int[4][5];2 二维数组可以有不同的长度。3 array[0][1] is 2.4.int[][] r = new int[2]; Answer: Invalidint[] x = new int[]; Answer: Invalidint[][] y = new int[3][]; Answer: Valid5. 因为我们需要排序list,排序list将改变list中的内容,唤起is1To9(grid[i])后grid数组中的内容也将改变。Grid中的内容将会改变,因此我们不能使用. 阅读全文
摘要:
Chapter 9 Strings and Text I/O 1.s1 == s2 => trues2 == s3 => falses1.equals(s2) => trues2.equals(s3) => trues1.compareTo(s2) => 0s2.compareTo(s3) => 0s1 == s4 => trues1.charAt(0) => Ws1.indexOf('j') => -1s1.indexOf("to") => 8s1.lastIndexOf('a') 阅读全文
摘要:
Chapter 8 Objects and Classes1. See the section "Declaring and Creating Objects."2. 构造方法是在创建一个对象使用new操作符时调用的。 构造方法没有返回类型,甚至连void也没有。数组是一个对象。 The default value for the elements of an array is 0 for numeric, false for boolean, ‘\u0000’ for char, null for object element type.(a) There is such 阅读全文