BigIntegerクラス
public static void main(String[] args) {
BigInteger b1 = new BigInteger("21111111111111111111111111111111111111111111111111111111111111");
BigInteger b2 = new BigInteger("11111111111111111111111111111111111111111111111111111111111111");
System.out.println(b1.add(b2));
System.out.println(b1.divide(b2));
System.out.println(b1.multiply(b2));
System.out.println(b1.subtract(b2));
}
BigDecimalクラス
public static void main(String[] args) {
System.out.println(12.0-11.9);
BigDecimal b1 = new BigDecimal("12.0");
BigDecimal b2 = new BigDecimal("11.9");
System.out.println(b1.subtract(b2));
BigDecimal b3 = new BigDecimal("12");
BigDecimal b4 = new BigDecimal("7");
System.out.println(b3.divide(b4,8,BigDecimal.ROUND_FLOOR));
System.out.println(b3.divide(b4,6,BigDecimal.ROUND_CEILING));
}
正規表現
public class RegexDemo {
public static void main(String[] args) {
boolean boo;
System.out.println("12".matches("\\d"));
System.out.println("1".matches("\\d"));
System.out.println("1".matches("\\d?"));
System.out.println("".matches("\\d?"));
System.out.println("".matches("\\d*"));
System.out.println("123".matches("\\d*"));
System.out.println("".matches("\\d+"));
System.out.println("1".matches("\\d+"));
System.out.println("123".matches("\\d+"));
System.out.println("12345".matches("\\d{6}"));
System.out.println("123456".matches("\\d{6}"));
System.out.println("123456".matches("\\d{3,6}"));
System.out.println("123".matches("\\d{3,6}"));
System.out.println("kljnlml"+"13".matches("[^(12)]"));
System.out.println("12345".matches("\\d{6,}"));
System.out.println("123456".matches("\\d{6,}"));
System.out.println("aBc".matches("[0-9]*"));
System.out.println("123".matches("[0-9]*"));
System.out.println("aBc".matches("[a-z]*"));
System.out.println("aBc".matches("[A-Z]*"));
System.out.println("aBc".matches("[A-z]*"));
System.out.println("13579".matches("[13579]*"));
System.out.println("13579".matches("[135]*"));
System.out.println("13355".matches("[^135]*"));
System.out.println("24668".matches("[^135]*"));
System.out.println("abc".matches("[a-z]*"));
System.out.println("aBc".matches("[a-z]*"));
System.out.println("aBc".matches("[A-Z]*"));
System.out.println("ABC".matches("[A-Z]*"));
System.out.println("aBc13".matches("\\w*"));
}
}