j a v a

package demo05;
 
public class Zy01 {
    public static void main(String[] args) {
        String s = "打劫!我有枪";
        exchange(s);
    }
 
    private static void exchange(String s) {
        String[] str = {"枪"};
        for (int i = 0; i < str.length; i++) {
            if (s.contains(str[i])) {
                s = s.replace(str[i], "*");
                System.out.println(s);
            }
        }
    }
}

 

package demo05;
 
public class Zy02 {
    public static void main(String[] args) {
        String s = "北京欢迎你";
        String s1 = s.replaceAll("北京", "郑州");
        String s2=s1.replaceAll("你", "你们");
        System.out.println(s2);
 
    }
}

 

package demo05;
 
public class Zy03 {
    public static void main(String[] args) {
        String s3 = "面向对象是以对象为核心..编程思想";
        char[] c = s3.toCharArray();
        char[] a = {c[0],c[c.length-1]};
        String a2 = String.copyValueOf(a);
        System.out.println(a2);
 
    }
}

 

package demo05;
 
public class Zy04 {
    public static void main(String[] args) {
        double d=3.1415926;
        System.out.println("d = " + d);
        String s = String.valueOf(d);
        System.out.println("字符串s的值: " + s);
    }
}

 

package demo05;
 
public class Zy05 {
    public static void main(String[] args) {
        String s="qwqe";
        if (s.length()>0) {
            System.out.println("此字符串不为空");
            System.out.println("s = " +  s.charAt(0));
            System.out.println("字符串的长度为" + s.length());
            System.out.println("第一个字符" +  s.charAt(0));
        }else {
            s="hello word";
            System.out.println("此字符串为空赋值为 hello word");
            System.out.println("字符串的长度为" + s.length());
            System.out.println("第一个字符" +  s.charAt(0));
        }
    }
}

 

package demo05;
 
public class Zy06 {
    public static void main(String[] args) {
        String s= "abca";
 
        System.out.println("a的下标为" + s.indexOf("a"));
        System.out.println("a的下标为" + s.lastIndexOf("a"));
 
 
        if (s.equals(s.charAt(0)) == s.equals(s.charAt(s.length()-1)))  {
 
            s="*bc*";
            System.out.println("s = " + s);
        }
    }
}

package demo05;
 
public class Zy07 {
    public static void main(String[] args) {
        int i1 = Integer.parseInt("123");
        System.out.println(i1);
        Integer inte1 = new Integer(i1);
        System.out.println(inte1);
        int i = 10;
        String str3 = String.valueOf(i);
        System.out.println(str3);
        String str4 = "" + i;
        System.out.println(str4);
    }
}

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值