zoukankan      html  css  js  c++  java
  • 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="      	你好java	 ";
    
        String f1=s2.replace("你好", "我是");
    
        String f2=s2.trim();
    
        System.out.println(f2);
    
        }
    
     
    
    }
  • 相关阅读:
    《代码大全2》阅读笔记02
    《代码大全2》阅读笔记01
    第二阶段冲刺第六天
    学习进度5
    构建之法阅读笔记03
    地铁进度记录
    学习进度4
    个人数组
    学习进度3
    构建之法阅读笔记02
  • 原文地址:https://www.cnblogs.com/a709898670/p/9382458.html
Copyright © 2011-2022 走看看