A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 18088086590 初级黑马   /  2016-9-15 00:47  /  385 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

加油记

正则表达式
        定义:是指一个用来描述或者匹配一系列符合某个语法规则的字符串的单个字符串。
                其实就是一种规则。有自己特殊的应用。
       
        字符类规则:
                [0-9]
                [abc]
                [^abc]
                [a-zA-Z]
                [a-d[m-p]]
                [a-z&&[m-p]]
       
        预定义字符类:
                .
                \.
                \d
                \D
                \s
                \S
                \w
                \W
        Greedy 数量词:
                x?
                x*
                x+
                x{1,3}
                x{4,}
                x{7}
        组:
                (Anything)
                \\1+
                $1

        字符串通过正则表达式来完成切割功能
                public String[] split(String regex);

                案例:把字符串”91 27 46 38 50”变成”27 38 46 50 91”  
                        用到了切割字符串
                        String转换成int
                        字符串的拼接(StringBuffer)

        字符串通过正则表达式来完成替换功能
                public String replaceAll(String regex,String replacement);

                案例:我要学编程(用到了组的概念)

        模式类Pattern和匹配器类Matcher用正则表达式完成匹配和查找获取功能
               
                String s = "我的手机是18511866260,我曾用过18987654321,还用过18812345678";
                String regex = "1[3578]\\d{9}";
                Pattern p = Pattern.compile(regex);
                Matcher m = p.matcher(s);
                boolean b = m.matches();                //用正则表达式完成匹配 也可以直接这样"abchehe".matches("a*c");
                while(m.find())        {                        //查找功能
                        System.out.println(m.group());        //获取功能
                }       
               

Math:类包含用于执行基本数学运算的方法,如初等指数、对数、平方根和三角函数。
        * public static int abs(int a)
        * public static double ceil(double a)
        * public static double floor(double a)
        * public static int max(int a,int b) min自学
        * public static double pow(double a,double b)
        * public static double random()
        * public static int round(float a) 参数为double的自学
        * public static double sqrt(double a)

Random:
        new Random();
        new Random(int a);

        nextInt();
        nextInt(100);
        100以内的随机数 1-100   r.nextInt(100)+1
                                (int)(Math.random()*100)+1;

System:
        * public static void gc()
        * public static void exit(int status)
        * public static long currentTimeMillis()
        * pubiic static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length)

BigInteger的概述
                 可以让超过Integer范围内的数据进行运算
                B:构造方法
                        * public BigInteger(String val)
                C:成员方法
                        * public BigInteger add(BigInteger val)
                        * public BigInteger subtract(BigInteger val)
                        * public BigInteger multiply(BigInteger val)
                        * public BigInteger divide(BigInteger val)
                        * public BigInteger[] divideAndRemainder(BigInteger val)

BigDecimal的概述
                * 由于在运算的时候,float类型和double很容易丢失精度,演示案例。
                * 所以,为了能精确的表示、计算浮点数,Java提供了BigDecimal
       
                * 不可变的、任意精度的有符号十进制数。
                * B:构造方法
                        * public BigDecimal(String val)
                * C:成员方法
                        * public BigDecimal add(BigDecimal augend)
                        * public BigDecimal subtract(BigDecimal subtrahend)
                        * public BigDecimal multiply(BigDecimal multiplicand)
                        * public BigDecimal divide(BigDecimal divisor)

Date类:
        构造方法:
                new Date();
                new Date(Long date);
        成员方法:
                getTime();
                setTime(Long date);
       
        SimpleDateFormat
                new SimpleDateFormat();
                new SimpleDateFormat(String pattern);

                public final String format(Date date);
                public Date parse(String time);
       
Calender:抽象类
        public static Calendar getInstance()
        public int get(int field)

        add();
        set();

        案例:判断手输入的年份是否是闰年

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马