12345678910111213141516171819202122232425262728293031323334353637383940 |
- package j1_java_basic.J20250525;
- /**
- * @author WanJl
- * @version 1.0
- * @title Demo05
- * @description 方法
- * @create 2025/5/25
- */
- public class Demo05 {
- /*
- 创建方法:
- 修饰符 返回值类型 方法名(参数列表){
- 方法体
- }
- */
- /**
- * 这是一个有参数,但是没有返回值的方法
- * 参数是int[][]数组arr
- * @param arr 形式参数
- */
- public static void printArray(int[][] arr){
- for (int i = 0; i < arr.length; i++) {
- for (int j = 0; j < arr[i].length; j++) {
- System.out.print(arr[i][j]);
- }
- System.out.println();
- }
- }
- public static void main(String[] args) {
- int[][] arr=new int[10][10];
- //调用方法
- //如果被调用的方法在同一个类中,可以直接通过方法名调用
- //不在同一个类中,需要通过【类名.方法名】调用
- //调用带有参数的方法时,需要传入参数,这时候的参数是实际参数。
- printArray(arr);
- }
- }
|