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