package jay_x_20100612;
import java.io.*;
import java.util.regex.Pattern;
public class jay_x_控制台输入各类型类实现 {
public static int v = 9;
public static void main(String[] args) {
InputStreamReader stdin = new InputStreamReader(System.in);
BufferedReader bufin = new BufferedReader(stdin);
try {
int i2 = Integer.parseInt(bufin.readLine());
System.out.print(i2);
// 判断输入的内容里面是否有数字
String s2 = bufin.readLine();
System.out.print(s2);
// 方法1:转换成字符数组,然后一个一个的比较是否含有数字
char ch3[] = s2.toCharArray();
Character ch6 = null;
// char ch4[]={'1','2'};
// char ch5=ch4[1];
for (int m = 0; m < ch3.length; m++) {
System.out.print(ch6.isDigit(ch3[m]));
}
// static boolean isDigit(char ch)
// 确定指定字符是否为数字。
// static boolean isDigit(int codePoint)
// 确定指定字符(Unicode 代码点)是否为数字。
// 方法2:正则表达式,比较整个字符串中是否符合数字格式
String s3 = bufin.readLine();
Pattern p = Pattern.compile("[0-9]*");
System.out.print(p.matcher(s3).matches());
// new a().a;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.print(input.readString());
System.out.print(input.readChar());
System.out.print(input.readInt());
System.out.print(input.readFloat());
System.out.print(input.readDouble());
System.out.print(v);
new a().u();
System.out.print(v);
}
}
class input {
static InputStreamReader in;
static BufferedReader reader;
static {
in = new InputStreamReader(System.in);
reader = new BufferedReader(in);
}
static String readString() {
String s = null;
try {
s = reader.readLine();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.exit(0);
}
return s;
}
static char readChar() {
String s = null;
char ch = 'a';
try {
s = reader.readLine();
ch = s.charAt(0);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.exit(0);
}
return ch;
}
static int readInt() {
String s;
int i = 0;
try {
s = reader.readLine();
i = Integer.parseInt(s);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.exit(0);
}
return i;
}
static float readFloat() {
String s;
float f = 0.0f;
try {
s = reader.readLine();
f = Float.parseFloat(s);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.exit(0);
}
return f;
}
static double readDouble() {
String s;
double d = 0.0;
try {
s = reader.readLine();
d = Double.parseDouble(s);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.exit(0);
}
return d;
}
}
class a {
void u() {
System.out.print(new jay_x_控制台输入各类型类实现().v++);
}
}
以上是我最近学习Java记录的笔记和自己参照书本和老师所讲编写的代码和注释。
有错误的地方,希望大家帮我指出。然后
1422942883这是我的QQ,欢迎各位学习编程的同学加我好友,
或者给我的个人主页留言(http://jayxigua.iteye.com/),一起讨论,学习。呵呵。