详细解决方案
请进
热度:435 发布时间:2005-12-28 20:54:00.0
请进
面向对象例子2-student
点击浏览该文件
public class student{ private String name = "me"; private int age=18; private int height=164; private int weight=120; private int num=3; public student(String m,int a,int h,int w,int n){ name = m; age=a; height=h; weight=w; num=n; } public void display(){ System.out.println("my name is "+name); System.out.println("my age is "+age); System.out.println("my height is "+height); System.out.println("my weight is "+weight); System.out.println("my xuehao is "+num); } }
class go{ public static void main(String[] args){ //内建基本数据类型,声明的同时已经分配内存空间 int i; //初始化,仅仅是给这个变量赋以一定的值 i=0; //用户自定义的数据类型,声明的同时并没有分配内存空间 student xiaoming; //初始化用户自定义类型的变量 //通过调用new操作运算符:首先分配内存存空间,然后初始化 //一个类的变量或对象(称作这个类的实例) xiaoming = new student("Mr.Ming",88,187,240,7); xiaoming.display(); System.out.println(); student zhang = new student("Miss.Z",18,168,100,1); zhang.display(); }
}
|
----------------解决方案--------------------------------------------------------
我共享了阿!大家有什么好东东都拿出来啊!!!!!
----------------解决方案--------------------------------------------------------
汗,那个论坛对游客连浏览权限都不给
----------------解决方案--------------------------------------------------------