程式碼如下:
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 main; | |
import test.test; | |
public class abc { | |
public static void pint(int n) { //print something integer | |
System.out.print(n+" "); | |
} | |
public static void pdouble(double n) {//print something double | |
System.out.print(n+" "); | |
} | |
public static void pstr(String str) { //print something | |
System.out.println(str); | |
} | |
public static void sint(int i, int j) { //swap something integer | |
test.i = j; | |
test.j = i; | |
} | |
public static void sdouble(double i, double j) { //swap something double | |
double temp = i; | |
i = j; | |
j = temp; | |
} | |
} |
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 test; | |
import main.*; | |
public class test { | |
public static int i = 10, j = 20; | |
public static void main(String args[]){ | |
String str1 = "abc"; | |
abc.pstr(str1); | |
abc.sint(i,j); | |
abc.pint(i); | |
abc.pint(j); | |
} | |
} |
abc 20 10
沒有留言:
張貼留言