-
-
Save ylxs90/eba37e592574814440b5c1d9e548d341 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.java.hxhua01; | |
public class TestMethod { | |
public static void main(String[] args) { | |
test01(1000); | |
test02(100, 6, 3);//1-100之間,可以被6整除,每行輸出3個 | |
System.out.println("****************"); | |
int s = add(3, 5); | |
System.out.println(s); | |
} | |
public static void test01(int a) { | |
int oddSum = 0; | |
int evenSum = 0; | |
for (int i = 0; i <= a; i++) { | |
if (i % 2 == 0) { | |
evenSum += i; | |
} else { | |
oddSum += i; | |
} | |
} | |
System.out.println("奇數和= " + oddSum); | |
System.out.println("偶數和= " + evenSum); | |
} | |
public static void test02(int a, int b, int c) { | |
for (j = 1; j <= a; j++) { | |
if (j % b == 0) { | |
System.out.println(j + "\t"); | |
} | |
if (j % (b / c) == 0) { | |
System.out.println(); | |
} | |
} | |
} | |
public static int add(int a, int b) { | |
int sum = a + b; | |
if (a == 3) { | |
return 0; | |
} | |
System.out.println("output"); | |
return sum; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment