Measure the test taker's understanding about the public t show (t a) method.

Source: Internet
Author: User
There are a lot of problems for xiaoxin. Well, there are still such problems today! Code As follows:

   Public     Class  Demo
{
Public Static T show < T > (T)
{
Return A;
}
Public Static Void Get ()
{
Int Myint = Show < Int > ( 2 );
}
}
In this Code, "T" after "static" indicates the expected data type. "T" in "show (t)" indicates the data type to be input. You can see it through the "get" method. Int Myint = show < Int > ( 2 );
This Int Is the type you want to enter. Here, the int can be replaced with the type you want at will ,.   Public StaticT show<T>(T) The T type of the parameter section is the same as that of the show front side! Not necessarily only put one parameter. In theory, N or more parameters can be put.   In this way, you can choose any parameter. Also, you can pass in multiple data type parameters.   For example:

    Public     Class  Demo
{
Public Static T show < T, x, y > (T a, x B, Y C)
{
Return A;
}
Public Static Void Get ()
{
Int Myint = Show < Int , String , Double > ( 2 , " ABC " , 4.0 );

}
}

when you first arrive, if an error occurs, please criticize and correct it! thank you for your guidance from Mr. Hao. Haha! next time! bye!

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.