Java Foundation Initialization issues

Source: Internet
Author: User

In the test initialization sequence, added generics, the result is to subvert the cognition.
I was executed first Qiu a = new Qiu (); How can I perform a static Huiyi first?!
-----------The result of the output--------------
Static Block Qiu
Static Huiyi
Block Qiu
Qiu
Block Qiu
Qiu
Block Huiyi
Huiyi

package fanxing01;import java.util.arraylist;import java.util.collection;import  java.util.list;//recall generic knowledge points class qiu{    static{         system.out.println ("Static block qiu");    }     {        system.out.println ("Block qiu");     }    qiu () {        system.out.println ("Qiu");     }    protected  int set (Integer a) {         return 1;    }     Protected  void set (double a) {//        return  1;    }}//class qiu2 extends qiu{//    private   void set (integer a) {//&NBsp;       //    }//}public class huiyi<t > extends Qiu{    static{         System.out.println ("Static huiyi");     }    huiyi () {         system.out.println ("Huiyi");    }     {        system.out.println ("Block huiyi");     }    public void set (T a) {         system.out.println (a);    }    public static<t> &NBSP;VOID&NBSP;SETFROMA2B (COLLECTION&LT;T&GT;&NBSP;ARR1,COLLECTION&LT;?&NBSP;SUPER&NBSP;T&GT;&NBSP;ARR2) {         for (T&NBSP;O&NBSP;:&NBSP;ARR1) {              arr2.add (o);        }         system.out.println (ARR2);    }    public static  Void main (String[] args)  {        qiu a =  new qiu ();        huiyi<integer> b =  New huiyi<> ();     }}


Java Foundation Initialization issues

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.