<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ## 反射方法的基本操作 ### 方法的反射: 1. 方法名稱加參數列表可以唯一確定一個方法 2. 通過方法對象來實現方法的功能,即把實例對象當成參數傳給方法對象 ~~~java public class MethodDemo1 { public static void main(String[] args) { //要獲取print(int ,int )方法 1.要獲取一個方法就是獲取類的信息,獲取類的信息首先要獲取類的類類型 A a1 = new A(); Class c = a1.getClass(); /* * 2.獲取方法 名稱和參數列表來決定 * getMethod獲取的是public的方法 * getDelcaredMethod自己聲明的方法 */ try { //Method m = c.getMethod("print", new Class[]{int.class,int.class}); Method m = c.getMethod("print", int.class,int.class); //方法的反射操作 //a1.print(10, 20);方法的反射操作是用m對象來進行方法調用 和a1.print調用的效果完全相同 //方法如果沒有返回值返回null,有返回值返回具體的返回值 //Object o = m.invoke(a1,new Object[]{10,20}); Object o = m.invoke(a1, 10,20); System.out.println("=================="); //獲取方法print(String,String) Method m1 = c.getMethod("print",String.class,String.class); //用方法進行反射操作 //a1.print("hello", "WORLD"); o = m1.invoke(a1, "hello","WORLD"); System.out.println("==================="); // Method m2 = c.getMethod("print", new Class[]{}); Method m2 = c.getMethod("print"); // m2.invoke(a1, new Object[]{}); m2.invoke(a1); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } class A{ public void print(){ System.out.println("helloworld"); } public void print(int a,int b){ System.out.println(a+b); } public void print(String a,String b){ System.out.println(a.toUpperCase()+","+b.toLowerCase()); } } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看