摘要:1 package com.test; 2 /** 3 * 打印出 100 以内的素数 4 * 素数又称为质数,它的定义是:只能被 1 和被自己整除的整数。其中, 1 不是素数,任何时候都不用考虑 1。 5 * @author Intel 6 * 7 */ 8 public class ...
阅读全文
摘要:Math.round(11.5)等於多少? Math.round(-11.5)等於多少?Math类中提供了三个与取整有关的方法:ceil、floor、round,这些方法的作用与它们的英文名称的含义相对应,例如,ceil的英文意义是天花板,该方法就表示向上取整,Math.ceil(11.3)的结果为...
阅读全文
摘要:1 import java.math.BigInteger; 2 3 public class SwitchTest { 4 public static void main(String[] args) { 5 BigInteger n=new BigInteger("4...
阅读全文
摘要:1 package com.helen.test; 2 3 import java.math.BigDecimal; 4 5 public class TestBigDecimal { 6 7 /** 8 * @param args 9 */10 publ...
阅读全文
摘要:三种方式获取对象类型: 1 package com.helen.test; 2 3 import java.util.Date; 4 5 public class Reflect { 6 public static void main(String[] args) { 7 Date da...
阅读全文
摘要:1 2 3 import java.io.File; 4 import java.io.FileInputStream; 5 import java.io.FileOutputStream; 6 import java.io.InputStream; 7 import java.io.Outp...
阅读全文
摘要:1 public class TestMode { 2 3 public static void main(String[] args) { 4 int x = -3; 5 int y = -10; 6 System.out.println...
阅读全文
摘要:1 public class Question1 { 2 3 public static void main(String[] args) { 4 String dir=""; 5 if(args.length!=1) 6 { 7 ...
阅读全文
摘要:1 public boolean accountBalance(double accountBalance){ 2 3 String regex1 ="[1-9]+\\d+[.][0]"; 4 String regex2 ="[0][.]\\d+"; 5 ...
阅读全文
摘要:1 public class SwingTest123 extends JFrame implements ActionListener { 2 3 JRadioButton boy, girl; 4 JLabel mess; 5 ButtonGroup group; 6...
阅读全文
摘要:1 class Person1 implements Comparable { 2 private Float height; 3 private String name; 4 5 Person1(float height) 6 { 7 t...
阅读全文
摘要:1 import java.util.Collections; 2 import java.util.Comparator; 3 import java.util.LinkedList; 4 5 class Person{ 6 private float height; 7 pr...
阅读全文
摘要:1 package com.cn.test20; 2 3 import java.sql.Connection; 4 import java.sql.DriverManager; 5 import java.sql.ResultSet; 6 import java.sql.SQLExceptio...
阅读全文
摘要:1 package Test8_19; 2 3 import java.util.Scanner; 4 5 public class CheckDate { 6 public static void main(String args[]) { 7 Chec...
阅读全文
摘要:无线程同步:存储数据: 1 public class Storage { 2 int data; 3 4 public int getData() { 5 return data; 6 } 7 8 public void setData(int ...
阅读全文
摘要:1 package Aug14.IO; 2 3 import java.io.*; 4 5 public class TestIO2 { 6 7 public static void main(String[] args) { 8 File file = new Fi...
阅读全文
摘要:Create a class Employee which extends from a class Person. The attributes of Person class are name, address, age. The attributes of the Employee clas...
阅读全文
摘要:1 package Aug14.IO; 2 3 import java.io.*; 4 import java.util.*; 5 import java.util.Map.Entry; 6 7 public class TestCurrentAccount { 8 9 ...
阅读全文
摘要:1 package Aug14.IO; 2 3 4 5 import java.io.*; 6 import java.util.*; 7 import java.util.Map.Entry; 8 9 class Student implements Serializa...
阅读全文
摘要:1 Object[] key_arr = hashmap.keySet().toArray(); 2 Arrays.sort(key_arr); 3 for (Object key : key_arr) { 4 Object value = hashmap.get(key); ...
阅读全文