摘要: package com.tu.oop.demo2;//java > classpublic class Person { //一个类即使什么都不写,它也会存在一个方法 //显示的定义构造器 //1、必须和类的名字相同 //2、必须没有返回类型,也不能写void String name; int ag 阅读全文
posted @ 2021-11-17 21:38 tuyin 阅读(48) 评论(0) 推荐(0)
摘要: public class Demo3 { public static void main(String[] args) { //非静态方法调用,类实例化之后才存在,所以应该在new之后再调用 //实际参数和形式参数的类型要对应 int add = new Demo3().add(2, 3); //静 阅读全文
posted @ 2021-11-17 17:46 tuyin 阅读(86) 评论(0) 推荐(0)
摘要: //值传递public class Demo4 { public static void main(String[] args) { int a = 1; System.out.println(a);//1(输出结果) Demo4.change(a); System.out.println(a);/ 阅读全文
posted @ 2021-11-17 17:23 tuyin 阅读(60) 评论(0) 推荐(0)