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);

 

转载于:https://www.cnblogs.com/caiyishuai/p/9662848.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值