设为首页 加入收藏

TOP

方法的形式参数是类名的时候如何调用
2019-09-01 23:16:20 】 浏览:11
Tags:方法 形式 参数 类名 时候 如何 调用

 

举例方法的形式参数是类名的调用

class Hello2 {
    public static void main(String[] args) {
        Student s = new Student();
        print(s);
    }


    public static void print(Student stu) {
        stu.name = "张三";
        stu.age = 23;
        stu.speak();
    }
}


class Student
{
    String name;
    int age;

    public void speak() {
        System.out.println(name + "..." + age);
    }
}

 

结果:

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇[Spring cloud 一步步实现广告系.. 下一篇@EnableAutoConfiguration自动配..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目