zoukankan      html  css  js  c++  java
  • Java之动手动脑

    动手动脑2

    请看以下代码,你发现了有什么特殊之处吗?

     1 package one;
     2 // MethodOverload.java
     3 // Using overloaded methods
     4 
     5 public class MethodOverload {
     6 
     7     public static void main(String[] args) {
     8         System.out.println("The square of integer 7 is " + square(7));
     9         System.out.println("
    The square of double 7.5 is " + square(7.5));
    10     }
    11 
    12     public static int square(int x) {
    13         return x * x;
    14     }
    15 
    16     public static double square(double y) {
    17         return y * y;
    18     }
    19 }

    该代码是向我们展示了重载的特性,

    满足以下条件的两个或多个方法构成“重载”关系:

    1)方法名相同;

    2)参数类型不同,参数个数不同,或者是参数类型的顺序不同。

     

  • 相关阅读:
    产品微谈
    SVN回滚机制
    super究竟是个啥?
    PM12条
    CocoaPods初体验
    UIView局部点击
    Memory cycles about Block
    About "self"
    openfire学习(一)
    WPF菜单和布局(2)
  • 原文地址:https://www.cnblogs.com/msdog/p/9786404.html
Copyright © 2011-2022 走看看