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/),一起讨论,学习。呵呵。
分享到:
相关推荐
NULL 博文链接:https://jayxigua.iteye.com/blog/698839
2012-06-12 12:22 10,537 C和C++字符串处理函数.txt 2012-06-12 12:21 8,825 c扫描器源码.txt 2012-06-12 12:39 505,110 c语言也能干大事全部板书(带书签)-感谢rupeng.com鹏友的整理.rar 2012-06-12 12:10 183,001 ...
NULL 博文链接:https://jayxigua.iteye.com/blog/686371
学生读书笔记共享-学生读书笔记共享系统的设计与实现代码-java-springboot-基于springboot的学生读书笔记共享系统项目-代码-源码-项目-系统-毕设-网站 1、技术栈:java,springboot,vue,ajax,maven,mysql,...
NULL 博文链接:https://jayxigua.iteye.com/blog/696076
java控制台版笔记本
笔记记录分享-笔记记录分享网站-笔记记录分享网站源码-笔记记录分享网站java代码-笔记记录分享网站设计与实现-基于springboot的笔记记录分享网站-基于Web的笔记记录分享网站设计与实现-笔记记录分享项目-笔记记录...
云的学习笔记-云的学习笔记系统-云的学习笔记系统源码-云的学习笔记管理系统-云的学习笔记管理系统java代码-云的学习笔记系统设计与实现-基于ssm的云的学习笔记系统-基于Web的云的学习笔记系统设计与实现-云的学习...
zookeeper云的学习笔记-云的学习笔记系统-云的学习笔记系统源码-云的学习笔记管理系统-云的学习笔记管理系统java代码-云的学习笔记系统设计与实现-基于ssm的云的学习笔记系统-基于Web的云的学习笔记系统设计与实现-...
2012-06-11 21:38 46,080 字符串的输入,删除练习.doc 2012-06-11 21:32 318,464 实验42:L298电机驱动程序(ATme.rar 2012-06-11 21:07 13,091 嵌入式拼音输入法C代码.rar 2012-06-11 21:12 64,623 巴特沃斯、...