java程序放在jcreator中运行,出现“类People是公共的,应在people.java中声明”,怎么声明??
publicclassPeople{intheight;Stringear;voidspeak(Strings){System.out.println(s);}}clas...
public class People
{
int height;
String ear;
void speak(String s)
{
System.out.println(s);
}
}
class A
{
public static void main(String args[])
{
People zhubajie;
zhubajie=new People();
zhubajie.height=170;
zhubajie.ear="两只大耳朵";
System.out.println("身高:"+zhubajie.height);
System.out.println(zhubajie.ear);
zhubajie.speak("师傅,咱们别去西天了,改去月宫吧");
}
} 展开
{
int height;
String ear;
void speak(String s)
{
System.out.println(s);
}
}
class A
{
public static void main(String args[])
{
People zhubajie;
zhubajie=new People();
zhubajie.height=170;
zhubajie.ear="两只大耳朵";
System.out.println("身高:"+zhubajie.height);
System.out.println(zhubajie.ear);
zhubajie.speak("师傅,咱们别去西天了,改去月宫吧");
}
} 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询