1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package com.lovecoding.oop01;
- /**
- * ClassName: Test01Method
- * Package: com.lovecoding.oop01
- * Description:
- *
- * @Author 爱扣钉-陈晨
- * @Create 2023/6/11 9:25
- * @Version 1.0
- */
- public class Test04Method {
- public static void main(String[] args) {
- Data d1 = new Data();
- d1.m = 10;
- d1.n = 20;
- System.out.println("m = " + d1.m + ", n = " + d1.n);
- //实现 换序
- Test04Method test = new Test04Method();
- test.swap(d1);
- System.out.println("m = " + d1.m + ", n = " + d1.n);
- }
- public void swap(Data data){
- int temp = data.m;
- data.m = data.n;
- data.n = temp;
- }
- }
- class Data{
- int m; //
- int n; //
- }
|