2013年2月3日
摘要: 1 package 编程练习题chapter6; 2 import java.util.Scanner; 3 public class Exercise6_01Extra { 4 public static void main(String[] args){ 5 Scanner input = new Scanner(System.in); 6 boolean[] isCovered = new boolean[99]; 7 8 int number = input.nextInt(); 9 while... 阅读全文
posted @ 2013-02-03 20:31 bailun 阅读(3748) 评论(0) 推荐(0) 编辑
摘要: 1 package 编程练习题chapter5; 2 import java.util.*; //我改了; 3 public class Exercise5_1 { 4 public static void main (String args[]) { 5 Scanner input = new Scanner(System.in); 6 7 System.out.print("Enter a number: "); 8 int number = input.nextInt(); 9 10 ... 阅读全文
posted @ 2013-02-03 20:26 bailun 阅读(3845) 评论(3) 推荐(0) 编辑
摘要: Chapter6Single-dimensionalArrays3声明数组时不分配内存。创建数组时分配内存。xis60Thesizeofnumbersis304.1. 数组中每个元素都有相同的类型。Answer:True2. 一旦数组被声明,大小不能改变。 Answer:False3. 一旦数组被创建,大小不能改变。Answer:True4. 数组中的元素必须是基本数据类型。Answer:False5. Whichofthefollowingstatementsarevalidarraydeclarations?inti=newint(30);Answer:Invaliddoubled[]=n 阅读全文
posted @ 2013-02-03 20:20 bailun 阅读(1278) 评论(0) 推荐(0) 编辑
摘要: Chapter5Methods1.Atleastthreebenefits:(1)Reusecode;(2)Reducecomplexity;(3)Easytomaintain.SeetheSections5.2and5.3onhowtodeclareandinvokemethods.Whatisthesubtledifferencebetween“definingamethod”and“declaringavariable”?Adeclarationusuallyinvolvesallocatingmemorytostoreavariable,butadefinitiondoesn’t.2. 阅读全文
posted @ 2013-02-03 20:19 bailun 阅读(1210) 评论(0) 推荐(0) 编辑
摘要: 1 package chapter7; 2 3 public class PassTwoDimensionalArray { 4 public static void main (String[] args) { 5 java.util.Scanner input = new java.util.Scanner(System.in); 6 7 int[][] m = new int[3][4]; 8 System.out.println("Enter " + m.length + " rows and " + 9 ... 阅读全文
posted @ 2013-02-03 20:18 bailun 阅读(1907) 评论(0) 推荐(0) 编辑
摘要: 1 package chapter6一维数组; 2 3 public class Arrays类 { 4 public static void main(String[] args){ 5 6 double[] numbers = {6.0, 4.4, 1.9, 2.9, 3.4, 3.5}; 7 java.util.Arrays.sort(numbers); 8 9 int[] list = {2, 4, 7, 10};10 System.out.println(java.util... 阅读全文
posted @ 2013-02-03 20:16 bailun 阅读(1227) 评论(0) 推荐(0) 编辑