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);
    
        }
    
     
    
    }
  • 相关阅读:
    WPF---数据模板(一)
    Oracle 相关知识
    Oracle 11g数据库详细安装步骤图解
    Mysql优化
    CSharp 相关知识点小结
    JS Date当前时间:获取日期时间方法在各浏览器中的差异
    【转】IE8浏览器无法保存Cookie的解决方法
    8 种提升 ASP.NET Web API 性能的方法
    DotNet 资源大全【转】
    DotNet 资源大全中文版【转】
  • 原文地址:https://www.cnblogs.com/a709898670/p/9382458.html
Copyright © 2011-2022 走看看