集册 Java实例教程 函数签名和重载

函数签名和重载

欢马劈雪     最近更新时间:2020-01-02 10:19:05

399
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
函数签名不考虑返回类型

public class Main {

  static double plusone(int n) {

    return n + 1.0;

  }
  /*
  nowjava
  */


  static double plusone(double x) {

    return x + 1.0;

  }


  static double plusone(String s) {

    return Double.parseDouble(s) + 1.0;

  }


  public static void main(String[] args) {

    System.out.println(plusone(15));

    System.out.println(plusone(6.23));

    System.out.println(plusone("123.2"));

  }//来自 NowJava.com - 时  代  Java

}