2018.7.28第一题作业答案 7个题

public class zuoye01 {
//boolean isEmpty(): 判断字符串是不是空串,如果是空的就返回true
 

    public static void main(String[] args) {

       // TODO Auto-generated method stub

       String str="";

       boolean b=str.isEmpty();

       System.out.println(b);

       }

       public boolean isEmpty(){

       zuoye01 str = null;

       if(str.isEmpty()) {

           return true;

           }else{

           return false;

           }

        }

       }
//char charAt(int index): 返回索引上的字符



public class zuoye02 {

 

     public static void main(String args[]) {

            String a = "adsadasdddd";

            char b = a.charAt(8);

            System.out.println(b);

        }

 

}
//String toLowerCase(): 字符串转成小写



public class zuoye03 {

 

    public static void main(String[] args) {

       // TODO Auto-generated method stub

String s="ABCDEFG";

String f=s.toLowerCase();

System.out.println(f);

    }

 

}
//String toUpperCase(): 字符串转成大写



public class zuoye04 {

 

    public static void main(String[] args) {

       // TODO Auto-generated method stub

String s="abcdefg";

String f=s.toUpperCase();

System.out.println(f);

    }

 

}
//String repalce(char oldChar, char newChar): 将字符串中的老字符,替换为新字符



public class zuoye05 {
    public static void main(String[] args){
        String s="你好java";

        String f=s.replace('你', '我');
        
        System.out.println(f);
        
    }
}
//String repalce(String old, String newstr): 将字符串中的老字符串,替换为新字符串




public class zuoye06 {

    public static void main(String[] args) {

   

    String s2="你好java";

    String f1=s2.replace("你好", "我是");

    System.out.println(f1);

    }

 

}
//String trim(): 去掉字符串两端空格



public class zuoye07 {

     

    public static void main(String[] args) {

    String s="你好java";

    String f=s.replace('你', '我');

    System.out.println(f);

    String s2="      \t你好java\t ";

    String f1=s2.replace("你好", "我是");

    String f2=s2.trim();

    System.out.println(f2);

    }

 

}

 

转载于:https://www.cnblogs.com/a709898670/p/9382458.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值