• String和StringBuilder


     1 import java.util.Collections;
     2 
     3 import static com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolver.length;
     4 //java字符串不会改变,除非重新赋值
     5 public class 字符串 {
     6     public static void main(String[] args) {
     7         String str = "44";
     8         int num = Integer.parseInt(str);
     9         str = String.valueOf(num);
    10 
    11         str = "dfa,sdf,adsf,asd,fasd,fas,df";
    12         String[] strings = str.split(",");
    13         str = String.join(",", strings);
    14 
    15         //左闭右开区间
    16         String string = str.substring(3,6);
    17 
    18         char c = string.charAt(1);
    19         int d = string.compareTo(string);
    20         String  ss = string.concat(string);
    21         boolean b = ss.contains("a");
    22         b = ss.startsWith("s");
    23         b = ss.endsWith("s");
    24         b = ss.isEmpty();
    25 
    26         b = ss.matches("a");
    27 
    28         ss = ss.replaceAll("sf" ,"asdf");
    29         ss = ss.replaceFirst("sf" ,"asdf");
    30 
    31         char[] chars = ss.toCharArray();
    32 
    33         ss = ss.toLowerCase();
    34         ss = ss.toUpperCase();
    35         ss = ss.trim();
    36 
    37         //StringBuilder
    38 
    39         StringBuilder stringBuilder = new StringBuilder("");
    40         stringBuilder.append("sdf");
    41         int aa = stringBuilder.capacity();
    42         int bb = stringBuilder.length();
    43 
    44         stringBuilder.delete(1, 2);//左闭右开
    45 
    46         stringBuilder.reverse();
    47         stringBuilder.deleteCharAt(1);
    48         stringBuilder.insert(0, "0000");
    49 
    50     }
    51 }
    我凝视这恒星,等待这那场风暴,我已经准备好了
  • 相关阅读:
    Kafk为什么这么快
    kafka消息格式演变
    kafka基础命令及api使用
    zookeeper && kafka && kafka manager开机自启动设置
    sqoop进行将Hive 词频统计的结果数据传输到Mysql中
    hive实例的使用
    使用HBase Shell命令
    Hadoop使用实例 词频统计和气象分析
    HDFS 操作命令
    第四次作业 描述HDFS体系结构、工作原理与流程
  • 原文地址:https://www.cnblogs.com/cheng5350/p/11488610.html
Copyright © 2020-2023  润新知