zoukankan      html  css  js  c++  java
  • Java学习——字符串

    import java.util.Scanner;
    
    
    public class cys1 {
    
        /**
         * @param args
         */
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            int a[];
            a=new int[5];
            for(int i=1;i<=4;i++)
            {
                a[i]=i;
                System.out.println(a[i]);
            }
            System.out.println("a的长度"+a.length);
    //        Scanner in =new Scanner(System.in);
    //        String cys;
    //        cys=in.nextLine();
    //        System.out.print(cys+","+"我是帅帅!!!");
    
    //        int b[][]=new int[2][5];
    //        for(int i=0;i<b.length;i++){
    //            for(int j=0;j<5;j++){
    //                b[i][j]=i*2+j;
    //                System.out.print(b[i][j]);
    //            }
    //            System.out.println();
    //        }
    //        System.out.println("b[0]的长度"+b[0].length);
            String s="abcdefg love";
            //返回第6个字符,字符从0开始
            System.out.println(s.charAt(6));
            System.out.println(s.toUpperCase());
            //返回从3到10的字串
            System.out.println(s.substring(3,10));
            String c="aas";
            //返回s-c
            System.out.println(s.compareTo(c));
            
        
        }
    
    }

     

    StringBuffer 为可以修改的字符串

            str.append("hhh");
            System.out.println(str);
            str.insert(1, "cys");
            System.out.print(str);

  • 相关阅读:
    iOS~runtime理解上篇
    iOS
    iOS-数据库+上传队列+runtime
    python3
    必应壁纸破解下载
    python3-django Mac下安装以及查看路径
    iOS
    iOS
    Tornado异步之-协程与回调
    iOS
  • 原文地址:https://www.cnblogs.com/caiyishuai/p/9662848.html
Copyright © 2011-2022 走看看