Java之方法重載篇(我重載了,你要如何來調用我。。)





# **一、課前引言**





  • 請看一下代碼,你發現什么特殊之處了嗎?

      public class MethodOverload {
          public static void main(String[] args) {
              System.out.println("The square of integer 7 is " + square(7));
              System.out.println("\nThe square of double 7.5 is " + square(7.5));
          }
          public static int square(int x) {
              return x * x;
          }
          public static double square(double y) {
              return y * y;
          }
      }
    




二、如何重載?如何調用?







免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM