zoukankan      html  css  js  c++  java
  • JAVA第七周学习总结

    String类

    String类的常用方法

    方法 目的 举例 运行&结果 注意
    length() 用来获取一个String对象的字符序列的长度 String china = "1945抗战胜利";int n1,n2;n1 = china.length();n2 = "小鸟fly”.length(); n1的值为9,n2的值为5
    equals(String s) 比较当前String对象的字符序列是否参与参数s指定的String对象字符序列相同 String tom = new String("天道酬勤"); String boy = new String("知心朋友");String jerry = new String("天道酬勤"); tom.equals(boy)的值为false,tom.equals(jerry)的值为ture,tom = jerry 的值为false 比较时忽略大小写
    starts With(String s) 判断当前String对象的字符序列前缀是否是参数指定的String对象s的字符序列 String tom = "天气预报,阴有小雨",jerry = "比赛结果,中国队赢得胜利"; tom.statsWith("天气")的值为true,jerry.statsWith("天气")的值为false endsWith(String s)方法恰与其相反,判断后缀
    compareTo(String s) 按字典序与参数指定的String对象s的字符序列比较大小,与s相同返回值0,大于s返回正值,小于s返回负值(a在Unicode中排序为97) String str = "abcde" str.compareTo("boy")小于0,str.compareTo("aba")大于0,str.compareTo("abcde")等于0 public int compareToIgnoreCase(String s)方法用法相同,此方法忽略大小写
    contains (String s) 判断当前String对象的字符序列是否包含参数s的字符序列 tom = "student" tom.contains("stu")的值为ture,tom.contains("ok")的值为false

    回到顶端

    码云链接及脚本截图

    unit8


    回到顶端

  • 相关阅读:
    PHP实现畅言留言板和网易跟帖样式
    关于MySql中自增长id设置初始值
    建议
    P3P解决cookie存取的跨域问题
    学习模板实例
    Mac 安装Bower
    webstorm for mac 破解步骤
    Mac上搭建php开发环境
    ios 开发之 -- 极光推送,发送自定义消息,进入制定页面
    ios开发之 -- 强制横屏
  • 原文地址:https://www.cnblogs.com/ln-0407/p/10702758.html
Copyright © 2011-2022 走看看