java API

1.4.1 简单的jAPI介绍

        在线API地址:Overview (Java SE 9 & JDK 9 )

        常用API String / ArrayList。

1.4.2 创建对象内容所在地区,方法,属性,地址

        方法区>栈地址>堆地址>常量词

        简单判断,提示双引号中的内容相互作用任在常量池,一方不为双引号则存入堆内存内存中

        查看反编译的代码

        第一步:拷贝路径

        第二步:打开文件夹,输入路径,回退一个文档找到javasepro文件夹;

        第三步:按命名找到运行的class文件,将其拖入程序编译,可获得计算机省略优化的代码

        

   1.4.4 String类的常用API

        ==    比较两个元素的地址

        string.equals(Object anObject)   //比较字符串内容

        string equalsIgnoreCase(String AnotherString)     //  忽略大小写比较内容

        String 的常用API方法

案例:登录账户后输入手机号(进行隐藏)

static Random r=new Random();
public static void main(String[] args) {
    String admin="admin";
    String passuser="passuser";
    Scanner sc=new Scanner(System.in);
    for (int i = 3; i > 0; i--) {
        String code = Code();
        System.out.println("请输入您的账号");
        String adminInput=sc.next();
        System.out.println("请输入您的密码");
        String passuserInput=sc.next();
        System.out.println("当前验证码为:"+code);
        System.out.println("请输入验证码");
        String CodeInput=sc.next();
        if(admin.equals(adminInput)&&passuser.equals(passuserInput)&&code.equalsIgnoreCase(CodeInput)){
            System.out.println("登录成功");
            System.out.println("请输入您的手机号码");
            String tel=sc.next();
            String Begin=tel.substring(0,3);
            String End=tel.substring(7);
            System.out.println(Begin+"****"+End);
            break;
        }else{
            System.out.println("用户名、密码、验证码输入错误");
            if(i>1){
                System.out.println("当前输入机会还剩"+(i-1)+"次");
            }else{
                System.out.println("账号已被锁定");
            }

        }
    }


}
public static String Code(){
    String code="";
    for (int i = 0; i < 5; i++) {
        int num=r.nextInt(2);
        if (num==0){
            code+=(char)(r.nextInt(10) + 48);
        }else if(num==1){
            code+=(char)(r.nextInt(25) + 65);
        }else{
            code+=(char)(r.nextInt(25) + 97);
        }
    }
    return code;
}

1.4.5   ArrayList类的常用API

        ArrayList list =new ArrayList();          // 创建一个不限制大小的list数组

        arr.add(E e)         //指定的元素e追加到此集合末尾

        arr.add(int index,E element)           //在此集合中的指定位置插入指定元素e 

        ArrayList<字符串类型>           //表示只能存储该种字符串类型  String / Integer

                

        

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值