zoukankan      html  css  js  c++  java
  • 黑马程序员——字符包含、两字符字符包含判断:应用于密码设置的限定等

    ---------------------- ASP.Net+Unity开发.Net培训、期待与您交流! ----------------------

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    <br>package temp01;
    //进制转换
    public class TempTest {
        public static void main(String args[]){
            //一个月30天(30进)
            int d = 361;
             
            String date = changeDay(d);
            sop(date); 
        }
        //把总天数根据天数转换为年月 日(以一年365天一个月30天转换)
        public static String changeDay(int d){
            int y = d/365;
            d -= 365*y;
            int m = d/30;
            d -= 30*m;
            return y+"Y"+m+"M"+d+"D";
        }
        public static void sop(Object obj){
            System.out.println(obj);
        }
    }

      

    --->两字符字符包含判断:应用于密码设置的限定等:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    package temp01;
     
    public class TempTest {
        public static void main(String args[]){
            //判断两个字符串中是否还有相同的字符
            String s1 = "xianyou_Liang";
            String s2 = "~!@#$%^&*()_+.,<>;:'"/?";
            sop(isContain(s1, s2));
             
        }
        public static boolean isContain(String s1, String s2){
            char[] c = s2.toCharArray();
            for(int i=0;i<c.length;i++){
                if(s1.contains(String.valueOf(c[i])))
                    return true;
            }
            return false;
        }
        public static void sop(Object obj){
            System.out.println(obj);
        }
    }

      

    ---------------------- ASP.Net+Unity开发.Net培训、期待与您交流! ----------------------

    用心-细心-专心-决心 学习就像爬大山,一步一步向前走 -态度决定高度-
  • 相关阅读:
    day25:接口类和抽象类
    vue1
    How the weather influences your mood?
    机器学习实验方法与原理
    How human activities damage the environment
    Slow food
    Brief Introduction to Esports
    Massive open online course (MOOC)
    Online learning in higher education
    Tensorflow Dataset API
  • 原文地址:https://www.cnblogs.com/xianyou-liang/p/8503363.html
Copyright © 2011-2022 走看看