小鸟的问题

LBS360252727 2008-03-25 08:18:49
/**字符串的艘寻*/
import java.io.*;
public class A003{
public static void main(String[] args){
String AA = "我是小炳炳";
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));//声明从健盘输入
System.out.println("AA = " + AA);

String CB;
System.out.print("请输入 = ");
CB = br.readLine(); //从键盘输入
int index = 0;
for(int i = 0; i < CB.length();i++)

index = AA.indexOf(CB,index);

System.out.println("他在这个位置上 = " + index);
}

}

运行不了!
...全文
106 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
bootupnow 2008-03-25
  • 打赏
  • 举报
回复
要try catch IO异常,或者throws出去

import java.io.*;

public class A003 {
public static void main(String[] args) throws IOException {
String AA = "我是小炳炳";
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// 声明从健盘输入
System.out.println("AA = " + AA);

String CB;
System.out.print("请输入 = ");
CB = br.readLine(); // 从键盘输入
int index = 0;
for (int i = 0; i < CB.length(); i++)

index = AA.indexOf(CB, index);

System.out.println("他在这个位置上 = " + index);
}

}

62,623

社区成员

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

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