public static void main(String[] args) { String a = "我"; String b = "是"; String c = "猪"; String d = a + b + c; System.out.print(d.replaceFirst("是", "")); } }建议你把String的几个replace方法研究一下,可以更灵活的使用
public class Test{
String a = "我"; String b = "是"; String c = "猪"; String d = a + b + c; public static void main(String[] args){ Test test = new Test() ;
你的意思是想把第二個字符去掉,是嗎?我也寫一種: 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) ); }}
public static void main(String[] args) { String a = "我"; String b = "是"; String c = "猪"; String d = a + b + c; System.out.print(d.replaceFirst("是", "")); } }
public static void main(String[] args) {
String a = "我";
String b = "是";
String c = "猪";
String d = a + b + c;
System.out.print(d.replaceFirst("是", ""));
}
}建议你把String的几个replace方法研究一下,可以更灵活的使用
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我是猪*/
}
}
//关键是这一局上面是测试代码,问题应该解决了
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) );
}}
后面应该是个空格吧
public static void main(String[] args) {
String a = "我";
String b = "是";
String c = "猪";
String d = a + b + c;
System.out.print(d.replaceFirst("是", ""));
}
}