zoukankan      html  css  js  c++  java
  • day11 Java学习(常见对象String类)

    常见对象( Scnner 键盘录入)

         nextInt ( ) 是键盘录入整数的方法。当录入整数时,其实录入的是整数和 。

         nexLine ( )是键盘录入字符串的方法,可以结束任意类型。

    常见对象( String类 )

                  * 解码 :将计算机读得懂的转换成我们读得懂的。

    String类的判断功能:

        * boolean 

             equlas( Object obj ):比较字符串内容是否相同,区分大小写。

             equlasIgnoreCase ( string str ) :比较字符串内容是否相同,不区分大小写。

             contains (string str ):判断大字符串中是否包含小字符串 。

             startsWith (string str ) :判断字符串是否以某个指定的字符串开头。

             endsWith ( String str ) :判断字符串是否以某个指定的字符串结尾。

             isEmpty( ) :判断字符串是否为空 。

    String类的获取功能:

             int length( ):获取每一个字符的个数 。

             char charAt ( int index ):获取指定索引位置的字符 。

             int indexOf ( int ch ):返回指定字符在此字符串中第一次出现的索引。

             int indexOf ( String str ):返回指定字符在此字符串中第一次出现的索引。

             int indexOf ( int ch  ,int fromIndex):返回指定字符在此字符串中从指定位置第一次出现的索引。

             int indexOf (  String str ,int fromIndex):返回指定字符在此字符串中从指定位置第一次出现的索引。

             String substring (int statr ) :从指定位置开始截取字符串,默认到尾部。

             String substring (int statr  ,int end) :从指定位置开始到指定位置结束截取字符串。

     

    String类的转换功能:

                 beyt [ ]   getBytes ( ) :把字符串转换为字节数组 。

                 char[ ]    toCharArray ( ) :把字符串转换为字符数组 。

                 static String  valueOf( char [ ]  css:把字符数组转换为字符串。

                 static String  valueOf( int  i ):把 int 类型的数据组转换为字符串。 

                                            注意:String类的valueOf 方法可以把任意类型的数据转成字符串。

                 

    String类的替换功能:

                 String  replace (char old , char new)

                 String  replace (string old , string new)

  • 相关阅读:
    phonegap_android配置文档
    JQueryMobile + PhoneGap 经验总结
    nand ECC 算法记录
    u-boot 2016.05 添加自己的board 以及config.h
    git commit 多行注释方法说明
    Ubuntu 下新建用户后无法sudo
    QT4.8.5 QComboBox 增加选择菜单记录
    Linux GPIO控制方法
    Qt5 can't find -LGL
    windows 端搭建nfs 服务器
  • 原文地址:https://www.cnblogs.com/feng0001/p/10897359.html
Copyright © 2011-2022 走看看