Quantcast
Channel: CSDN博客推荐文章
Viewing all articles
Browse latest Browse all 35570

Java判断字符串是字符或数字

$
0
0

方法传入参数是String类型,方法判断该字符串是否全是英文字符或全是数字:

①判断是否全是英文字符:

public boolean isString(String s) {
		return s.matches("^[a-zA-Z]*");
	}


②判断是否全是数字:

public boolean isNumber(String s) {
		Pattern pattern = Pattern.compile("^[0-9]*");
		return pattern.matcher(s).matches();
	}

作者:huhui_bj 发表于2013-4-22 11:51:52 原文链接
阅读:52 评论:0 查看评论

Viewing all articles
Browse latest Browse all 35570

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>