使用java中标准类库中的一个类的类里面的方法来编写一个小程序
double d = 2;
d = Math.sqrt(d);
System.out.println(d); // 1.414
math 有很多相关的计算,.有平方根,平方 都有
Math 前面有个同学问如何实现剪刀石头布的问题 可以用到随机数来实现
package com.zuidaima.util;
import java.io.Console;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class RegexTestHarness {
public static void main(String[] args) {
Console console = System.console();
if (console == null) {
System.err.println("No console.");
System.exit(1);
}
while (true) {
Pattern pattern = Pattern.compile(console.readLine("%nEnter your regex: "));
Matcher matcher = pattern.matcher(console.readLine("Enter input string to search: "));
boolean found = false;
while (matcher.find()) {
console.format("I found the text \"%s\" starting at index %d " +
"and ending at index %d.%n",
matcher.group(), matcher.start(), matcher.end());
found = true;
}
if (!found) {
console.format("No match found.%n");
}
}
}
}