为什么在运行时,老是提示str1=buf.nextLine();是错的

取个名字八个字 2012-03-21 11:12:38
import java.util.*;
public class zys9
{
public static void main(String[] args)
{
String str,str2="";
int n,i;
char c,str1;
Scanner buf=new Scanner(System.in);
System.out.print("请输入字符串str:");
str=buf.nextLine();
n=str.length();
System.out.print("请输入一个要消除的字符str1:");
str1=buf.nextLine();
for(i=0;i<n;i++)
{
c=str.charAt(i);
if(str1!=c)
str2=str2+c;

}


System.out.println(str2);

}
}
...全文
59 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

23,407

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧