开始熟悉java了

开始学习了,强迫自己,下面先熟悉一个小程序

code:


public class People {
float hight,weight;
String head,ear,mouth;
void speak(String s)

{
System.out.println(s);
}
}


code:


class A extends People
{
public static void main(String[] args)
{
People zhubajie;
zhubajie=new People();
zhubajie.weight=200f;
zhubajie.hight=1.70F;
zhubajie.head="大头";
zhubajie.ear="两只大耳朵";
zhubajie.mouth="一只大嘴";
System.out.println("重量"+zhubajie.weight+",身高" +zhubajie.hight);
System.out.println(zhubajie.head+","+zhubajie.mouth+","+zhubajie.ear);
zhubajie.speak("师傅,咱们别去西天了,改去月宫吧");
}
}


运行结果:

quote:

重量200.0,身高1.7
大头,一只大嘴,两只大耳朵
师傅,咱们别去西天了,改去月宫吧

随机日志

此条目发表在 书自己-Mine 分类目录。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

:biggrin :exclaim :razz :idea :surprised :question :twisted :mrgreen :neutral :smile more »