当前位置: 技术问答>java相关
最简单的程序错误:见内
来源: 互联网 发布时间:2015-04-30
本文导语: import java.io.*; /* JHelloWorld @author zhf @version helloworld 1.0 */ class JHelloWorld { public static void main(String[] args) { String str; DataInputStream stream=new DataInputStream(System.in); System.out.println("Please Enter Words:n"); str=s...
import java.io.*;
/*
JHelloWorld
@author zhf
@version helloworld 1.0
*/
class JHelloWorld
{
public static void main(String[] args)
{
String str;
DataInputStream stream=new DataInputStream(System.in);
System.out.println("Please Enter Words:n");
str=stream.readline();//不能识别
System.out.println(str);
try
{
stream.close();
}
catch(IOException e)
{
}
}
}
错误提示:
---------- javaC ----------
JHelloWorld.java:14: cannot resolve symbol
symbol : method readline ()
location: class java.io.DataInputStream
str=stream.readline();
^
1 error
/*
JHelloWorld
@author zhf
@version helloworld 1.0
*/
class JHelloWorld
{
public static void main(String[] args)
{
String str;
DataInputStream stream=new DataInputStream(System.in);
System.out.println("Please Enter Words:n");
str=stream.readline();//不能识别
System.out.println(str);
try
{
stream.close();
}
catch(IOException e)
{
}
}
}
错误提示:
---------- javaC ----------
JHelloWorld.java:14: cannot resolve symbol
symbol : method readline ()
location: class java.io.DataInputStream
str=stream.readline();
^
1 error
|
是的方法名写错了,readLine();
|
我给你改了一下
import java.io.*;
/*
JHelloWorld
@author zhf
@version helloworld 1.0
*/
class JHelloWorld
{
public static void main(String[] args)
{
try
{
String str;
DataInputStream stream=new DataInputStream(System.in);
System.out.println("Please Enter Words:n");
str=stream.readLine();//不能识别
System.out.println(str);
stream.close();
}
catch(IOException e)
{
}
}
}
你的readline()应该这样写readLine(),“l”应为大写
import java.io.*;
/*
JHelloWorld
@author zhf
@version helloworld 1.0
*/
class JHelloWorld
{
public static void main(String[] args)
{
try
{
String str;
DataInputStream stream=new DataInputStream(System.in);
System.out.println("Please Enter Words:n");
str=stream.readLine();//不能识别
System.out.println(str);
stream.close();
}
catch(IOException e)
{
}
}
}
你的readline()应该这样写readLine(),“l”应为大写