2013年2月14日
摘要: package 编程练习题chapter9;import java.util.Scanner;public class Exercise9_1 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter a string for SSN: "); String s = input.nextLine(); if (isValidSSN(s)) { ... 阅读全文
posted @ 2013-02-14 22:04 bailun 阅读(2637) 评论(0) 推荐(0) 编辑
摘要: package 编程练习题chapter8;import java.util.GregorianCalendar;public class Exercise8_5 { public static void main(String[] args) { GregorianCalendar calendar = new GregorianCalendar(); System.out.println("Year is " + calendar.get(GregorianCalendar.YEAR)); System.out.println("Month ... 阅读全文
posted @ 2013-02-14 22:02 bailun 阅读(9279) 评论(2) 推荐(0) 编辑
摘要: package 编程练习题chapter7;import java.util.Scanner;public class Exercise7_1 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a 4 by 4 matrix row by row: "); double[][] m = new double[4][4]; for (int i = 0; i < 4; i+... 阅读全文
posted @ 2013-02-14 22:00 bailun 阅读(1973) 评论(15) 推荐(1) 编辑
摘要: package chapter9字符串和文本IO;import java.util.Scanner;public class PalindromeIgnoreNonAlphanumeric { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a string: "); String s = input.nextLine(); System.out.println("Igno... 阅读全文
posted @ 2013-02-14 21:59 bailun 阅读(1114) 评论(0) 推荐(0) 编辑
摘要: 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 ... 阅读全文
posted @ 2013-02-14 21:56 bailun 阅读(865) 评论(0) 推荐(0) 编辑
摘要: 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中的内容将会改变,因此我们不能使用. 阅读全文
posted @ 2013-02-14 21:44 bailun 阅读(815) 评论(0) 推荐(0) 编辑
摘要: 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') 阅读全文
posted @ 2013-02-14 21:43 bailun 阅读(2794) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2013-02-14 21:39 bailun 阅读(3390) 评论(0) 推荐(0) 编辑