Java Basics: The main method of the Reflection class

Source: Internet
Author: User


Notice that the reflection Main method differs from the normal method:


this is because of the JDK design problem, the jdk1.4 version is different from the 1.5 version, as follows

Jdk1.4: Publicobject Invoke (Object obj,object[] args), which is byjdk1.4syntax, you need to pass an array as a parameter to theInvokemethod, each element in the array corresponds to a parameter in the called method, and 1.4 goes back and splits the element in the fractional group as an argument.


Jdk1.5 :  Public object Invoke (Object Obj,object ... args)



for the JDK backwards compatibility, invoking the Invoke method cannot simply pass in a string array, and it needs to wrap an object array outside. Or a strong turn. The string array is object, so you don't have to split it.
invoke (NULL, new object[]{new string[]{"1", "2"}});
invoke (null, (Object)new string[]{"1", "2"});

Java Basics: The main method of the Reflection class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.