the souce code of thinking in java (1-10),if you want to learn java ,please read it and you will get

源代码在线查看: bool.java

软件大小: 118 K
上传用户: rylzll
关键词: java you thinking please
下载地址: 免注册下载 普通下载 VIP

相关代码

				//: c03:Bool.java
				// Relational and logical operators.
				// From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
				// www.BruceEckel.com. See copyright notice in CopyRight.txt.
				import com.bruceeckel.simpletest.*;
				import java.util.*;
				
				public class Bool {
				  static Test monitor = new Test();
				  public static void main(String[] args) {
				    Random rand = new Random();
				    int i = rand.nextInt(100);
				    int j = rand.nextInt(100);
				    System.out.println("i = " + i);
				    System.out.println("j = " + j);
				    System.out.println("i > j is " + (i > j));
				    System.out.println("i < j is " + (i < j));
				    System.out.println("i >= j is " + (i >= j));
				    System.out.println("i 				    System.out.println("i == j is " + (i == j));
				    System.out.println("i != j is " + (i != j));
				    // Treating an int as a boolean is not legal Java:
				//! System.out.println("i && j is " + (i && j));
				//! System.out.println("i || j is " + (i || j));
				//! System.out.println("!i is " + !i);
				    System.out.println("(i < 10) && (j < 10) is "
				       + ((i < 10) && (j < 10)) );
				    System.out.println("(i < 10) || (j < 10) is "
				       + ((i < 10) || (j < 10)) );
				    monitor.expect(new String[] {
				      "%% i = -?\\d+",
				      "%% j = -?\\d+",
				      "%% i > j is (true|false)",
				      "%% i < j is (true|false)",
				      "%% i >= j is (true|false)",
				      "%% i 				      "%% i == j is (true|false)",
				      "%% i != j is (true|false)",
				      "%% \\(i < 10\\) && \\(j < 10\\) is (true|false)",
				      "%% \\(i < 10\\) \\|\\| \\(j < 10\\) is (true|false)"
				    });
				  }
				} ///:~
							

相关资源