import java.io.*;
public class hello8
{
public static void main(String args[])throws NumberFormatException,
IOException
{
String s=" ";
char a=' ';
int h,i,j;
h=i=j=0;
System.out.println("请输入一个字符串:");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
s=br.readLine();
for(int f=0;f<s.Lenght();f++){
a=charAt(f);
if(a>'a'&&a<'z')
h++;
else
if(a>'0'&&a<'9')
i++;
else
j++;
}
System.out.println("字母"+h+"个");
System.out.println("数字"+i+"个");
System.out.println("其他字符"+j+"个");
}
} 这个总是出现这个错误:c:\java>javac hello8.java
hello8.java:15: 找不到符号
符号: 方法 Lenght()
位置: 类 java.lang.String
for(int f=0;f<s.Lenght();f++
^
hello8.java:16: 找不到符号
符号: 方法 charAt(int)
位置: 类 hello8
a=charAt(f);
请问前辈 问题出在哪里?
^
public class hello8
{
public static void main(String args[])throws NumberFormatException,
IOException
{
String s=" ";
char a=' ';
int h,i,j;
h=i=j=0;
System.out.println("请输入一个字符串:");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
s=br.readLine();
for(int f=0;f<s.Lenght();f++){
a=charAt(f);
if(a>'a'&&a<'z')
h++;
else
if(a>'0'&&a<'9')
i++;
else
j++;
}
System.out.println("字母"+h+"个");
System.out.println("数字"+i+"个");
System.out.println("其他字符"+j+"个");
}
} 这个总是出现这个错误:c:\java>javac hello8.java
hello8.java:15: 找不到符号
符号: 方法 Lenght()
位置: 类 java.lang.String
for(int f=0;f<s.Lenght();f++
^
hello8.java:16: 找不到符号
符号: 方法 charAt(int)
位置: 类 hello8
a=charAt(f);
请问前辈 问题出在哪里?
^
解决方案 »
- 一个Frame添加了Panel 报错:at java.awt.Container.addImpl(Unknown Source)
- java 也能直接操作硬件?(不通过*.c, *.cpp 等)
- "Fri Jun 24 08:20:21 CST 2011"转换日期型?
- 请教:怎么计算每天网站访问量。
- 怎样解决运行javaGUI程序后,整个窗体就没有相应的问题
- java + oracle 的数据库操作问题!
- 我想散点分
- 正在读ing think in java,有没有书里的smalltalk的编程工具下载。
- 交流一下考scjd或者scwd的经验!
- python自动安装工具easy_install 安装 代理如何配置
- java每月月底定时执行指定任务
- 跪求一个组合算法
换成
lenght()
改成
s.lenght()a=charAt(f);
改成
a=s.charAt(f);
2> a = s.charAt(f);
3> public class Hello8(用大写吧)
import java.io.*;public class hello8 { public static void main(String args[]) throws NumberFormatException, IOException {
String s = " ";
char a = ' ';
int h, i, j;
h = i = j = 0;
System.out.println("请输入一个字符串:");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
s = br.readLine();
System.out.println(s);
for (int f = 0; f < s.length(); f++) {
a = s.charAt(f);
if (a >= 'a' && a <= 'z')
h++;
else if (a >= '0' && a <= '9')
i++;
else
j++;
}
System.out.println("字母" + h + "个");
System.out.println("数字" + i + "个");
System.out.println("其他字符" + j + "个");
}
}
hello8.java:14: 找不到符号
符号: 方法 lenght()
位置: 类 java.lang.String
for(int f=0;f<s.lenght();f++){
^
hello8.java:15: 找不到符号
符号: 方法 charAt(int)
位置: 类 hello8
a=charAt(f);
^
2 错误
char a = ' ';
int h, i, j;
h = i = j = 0;
System.out.println("请输入一个字符串:");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
s = br.readLine();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(s);
for (int f = 0; f < s.length(); f++) {
a = s.charAt(f);
if (a >= 'a' && a <= 'z')
h++;
else if (a >= '0' && a <= '9')
i++;
else
j++;
}
System.out.println("字母" + h + "个");
System.out.println("数字" + i + "个");
System.out.println("其他字符" + j + "个");这样没错,,我试过了,,,是不是你jdk有问题啊。