- import java.io.InputStream;
- import java.util.Scanner;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class 利用正则表达式来判断一个字符串是否是数字 {
- public static
void main(String args[]) {
- Scanner s = new Scanner(System.in);
- String ss = s.next();
- String str="\\d{3,}";
- Pattern p =Pattern.compile(str);
- Matcher m = p.matcher(ss);
- while(m.find()){
- System.out.print("LLLLMMMM****");
- }
- }
- }
-
-
- public class 字符串转换为数字 {
- public static
int convInt(String aa){
- return Integer.parseInt(aa);
- }
- public static
int[] convIntArray(String str[]){
- if(str==null){return
new int[0];}
- int ss[] = new
int [str.length];
- for(int i=0;i<str.length;i++){
- ss[i]=convInt(str[i]);
- }
- return ss;
- }
- public static
void main(String args[]){
- String s = "45679";
-
- String str[] ={"295","665","32","4"};
- int [] a =convIntArray(str);
- System.out.println("把str转换为整形数组后输出为:");
- for(int i=0;i<a.length;i++){
- System.out.print(" "+a[i]);
- }
- System.out.println("\n5的3次方是"+Math.pow(5,
3));
- System.out.println("100的平方根是:"+Math.sqrt(100));
- System.out.println("5的平方根的整数值是:"+Math.round(Math.sqrt(5)));
- }
- }
posted on
2013-02-20 20:23
蜜雪薇琪
阅读(
305)
评论()
编辑
收藏
举报