带返回值的方法

This commit is contained in:
seahi 2024-09-09 20:52:49 +08:00
parent b495294af3
commit 52b68a5706
2 changed files with 13 additions and 0 deletions

11
src/Example20.java Normal file
View File

@ -0,0 +1,11 @@
public class Example20 {
public static void main(String[] args) {
int area = getArea(3, 5);
System.out.println("The area is " + area);
}
public static int getArea(int x, int y) {
int temp = x * y;
return temp;
}
}

2
src/Example21.java Normal file
View File

@ -0,0 +1,2 @@
package PACKAGE_NAME;public class Example21 {
}