A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 陈俊洁 中级黑马   /  2016-3-15 19:45  /  1607 人查看  /  8 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

class Student {
        public void study() {
                System.out.println("Good Good Study,Day Day Up");
        }
}

class StudentDemo {
        public Student getStudent() {
                return new Student();
        }
}

class StudentTest2 {
        public static void main(String[] args) {
                StudentDemo sd = new StudentDemo();
                Student s = sd.getStudent(); //new Student(); Student s = new Student();
                s.study();

8 个回复

倒序浏览
就算难,也要坚持下去。。。fighting!
回复 使用道具 举报
表示 也有点晕
回复 使用道具 举报
加油必胜
回复 使用道具 举报
android表示不懂
回复 使用道具 举报
楼主满满的正能量啊~~~
回复 使用道具 举报
正常,他是以类名做为了返回值类型,所以在访问的时候要通过创建该类的对象才能直接访问
回复 使用道具 举报
多情浪子 发表于 2016-3-22 08:03
正常,他是以类名做为了返回值类型,所以在访问的时候要通过创建该类的对象才能直接访问 ...

谢谢了。。。。。。。。。。。。。。
回复 使用道具 举报
还好啊,不晕,这是数据类型罢了,引用型数据类型(数组,对象,类)
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马