请高手帮忙看下 这个要怎么改过来

无聊司马 2010-04-08 07:49:52
代码如下:
提示错误为:
无法取消引用int
import java.io.*;
public class Testl{
public static void main(String[] args){
FileReader in=null;
int s=0;
int index;
int Index;
int digit;
int k;
try{
in=new FileReader("E:/Testl.java");
while((s=in.read())!=-1){
//System.out.print((char)s);
for(int i=0;i<s.length;i++){
char c=s.charAt(i);
if(c>'a'&&c<'z'){
index++;
}
if(c>'A'&&c<'Z'){
Index++;
}
if(c>0&&c<9){
digit++;
}else{
k++;
}
}
System.out.println("此文本中小写字母有"+index+"个");
System.out.println("此文本中大写字母有"+Index+"个");
System.out.println("此文本中数字有"+digit+"个");
System.out.println("其它字母有"+k+"个");
}
in.close();
}catch(FileNotFoundException e){
System.out.println("没有找到指定文件!");
}
catch(IOException e){
e.printStackTrace();
}
}
}
...全文
198 6 打赏 收藏 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yangweiqing2 2010-04-09
  • 打赏
  • 举报
回复
s声明的是int类型,怎么用成字符串类型了?
dickli1986 2010-04-08
  • 打赏
  • 举报
回复
String str = String.valueof(s)
laker_914 2010-04-08
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 sd01397055 的回复:]

s声明的是int类型,怎么用成字符串类型了?
[/Quote]

正确
无聊司马 2010-04-08
  • 打赏
  • 举报
回复
怎么处理啊??
我不是很懂这个问题
sd01397055 2010-04-08
  • 打赏
  • 举报
回复
s声明的是int类型,怎么用成字符串类型了?

62,620

社区成员

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

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