提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用静态类变量的示例
public class Main { static int nbfunccalls = 0;/* 来 自 时代Java - nowjava.com*/ static int square(int x) { nbfunccalls++; return x * x; } static boolean isOdd(int p) { nbfunccalls++; if ((p % 2) == 0) return false; else return true; } static double distance(double x, double y) { /** 来 自 n o w j a v a . c o m - 时 代 Java **/ double result; nbfunccalls++; if (x > y) result = x - y; else result = y - x; return result; } static void display(double x, double y) { nbfunccalls++; System.out.println("(" + x + "," + y + ")"); } static double ff(double xx) { double xx1 = 0.0; return xx1; } public static void main(String[] args) { display(3, 2); display(square(2), distance(5, 9)); int p = 123124345;