String a = "我";
String b = "是";
String c = "猪";
String d = a + b + c;
System.out.print(d);
/* output
我是猪
请问如何改变或者通过一定的转换让b的值变成一个空字符? 前提是在转换前b 是一个String  
我想输出 /* output
我猪

解决方案 »

  1.   

    public class Test1 {

    public static void main(String[] args) {
    String a = "我";
    String b = "是";
    String c = "猪";
    String d = a + b + c;
    System.out.print(d.replaceFirst("是", ""));
    }
    }建议你把String的几个replace方法研究一下,可以更灵活的使用
      

  2.   


    public class Test{
     
       String a = "我";
       String b = "是";
       String c = "猪";
       String d = a + b + c;
     public static void main(String[] args){
      Test test = new Test() ;
      
      System.out.println(test.d.replace("是",""));
      /* output我是猪*/
      }
    }
      

  3.   

     System.out.println(test.d.replace("是",""));
    //关键是这一局上面是测试代码,问题应该解决了
      

  4.   

    你的意思是想把第二個字符去掉,是嗎?我也寫一種:
    public class test {
      public static void main(String[] args) {
        String a = "我";
        String b = "是";
        String c = "猪";
        String d = a + b + c;
        System.out.print( d.substring(0, 1) + d.substring(2) );
      }}
      

  5.   

    System.out.println(test.d.replace("是"," ")); 
    后面应该是个空格吧
      

  6.   

    String类有很多方法,可以好好研究一下~~~~
      

  7.   

    public class Test1 { 
        
        public static void main(String[] args) { 
            String a = "我"; 
            String b = "是"; 
            String c = "猪"; 
            String d = a + b + c; 
            System.out.print(d.replaceFirst("是", "")); 
        }