---
# System prepended metadata

title: <h1>松林Java04筆記2019/11/25

---

# <h1>松林Java04筆記2019/11/25

a.二維陣列
![](https://i.imgur.com/HXa3GA6.png)
public class TwoArrayDemo{
	public static void main(String args[]){
		int sum=0;
		int sale[][]={{32,58,65,70},{43,85,92,65}};
		for(int i=0;i<sale.length;i++){
			for(int j=0;j<sale[i].length;j++){
			sum+=sale[i][j];
			System.out.print(sale[i][j]+" ");
			}
			System.out.println();
		}
		
		System.out.println(sum);
	}

}

b.函式 
![](https://i.imgur.com/RUikcGs.png)

public class MethodDemo{

	public static void main(String args[]){

	star();
	System.out.println("Hello");
	star();
	}
	
	public static void star(){
		for(int i=1;i<=20;i++){
			System.out.print("*");
		}
		System.out.println();
	}


}

c.NumberMethod
![](https://i.imgur.com/1O4IdfL.png)
public class NumberMethod{
	public static void main(String args[]){
		int a=10;
		number_add(a);
		System.out.println("main a is:"+a);
	}

	public static void number_add(int a){

		a+=10;
		System.out.println("number_add a is:"+a);

	}
}

d.ReturnMethod
![](https://i.imgur.com/NTQK94G.png)
public class ReturnMethod{
	public static void main(String args[]){

	double num;
	num=add_length(7,3);
	System.out.println("num="+num);
	System.out.println("num="+add_length(7,3));

	}
	public static double add_length(int m,int n){

	return Math.sqrt(m*m+n*n);
	}
}


e.ArrayMethod
![](https://i.imgur.com/nkTdF4W.png)
public class ArrayMethod{

	public static void main(String args[]){

	int A[][]={{25,,63,94,18,21},{37,45,29,51,92}};
	array_add(A);

	}
	public static void array_add(int A[][]){
		for(int i=0;i<A.length;i++){
			for(int j=0;j<A[i].length;j++){
				System.out.print(A[i][j]+" ");
			}
			System.out.println();
		}
	}
}

f.ArrayMethodClass
![](https://i.imgur.com/GBowqAI.png)
public class ArrayMethodClass{
	public static void main(String args[]){
		int B[]={1,2,3,4,5};

		aMethod(B);
		for(int i=0;i<B.length;i++){

			System.out.print("B陣列:"+B[i]+" ");
		}
	}
	public static void aMethod(int A[]){
		for(int i=0;i<A.length;i++){
			A[i]+=10;
			System.out.print("A陣列:"+A[i]+" ");
		}
		System.out.println();
	}

}