带返回值的方法
This commit is contained in:
parent
b495294af3
commit
52b68a5706
11
src/Example20.java
Normal file
11
src/Example20.java
Normal 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
2
src/Example21.java
Normal file
@ -0,0 +1,2 @@
|
||||
package PACKAGE_NAME;public class Example21 {
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user