What are wildcards?

Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.

What are wildcards?

Rating:

In Java, wildcards mean unknown types. They are represented using the ? symbol. Wildcards are used in Java to provide flexibility of using different type parameters with the generics code.

Wildcards are of the following two types:

  • Unbounded wildcards: These are the wildcards without any upper or lower bound. An unbounded wildcard is the same as <? extends Object>.


  • Bounded wildcards: These wildcards have either an upper or a lower bound. They are of the following two types:

    • Wildcards with an upper bound: These are the wildcards with the upper bound specified. An example of such wildcards is as follows:

      <? extends ClassOne>: It represents a family of subtypes of type ClassOne. This means that an unknown type is a subtype of ClassOne.


    • Wildcards with a lower bound: These are the wildcards with the lower bound specified. An example of such wildcards is as follows:

      <? super ClassOne>: It represents a family of supertypes of type ClassOne. This means that an unknown type is a supertype of ClassOne.


Rating:



Other articles

Click here to Article home

 
uCertify.com | Our Company | Articles | Privacy | Security | Contact Us | News and Press Release | uCertify India
MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD Cisco Certification: CCNA, CCENT, A+, Network+, Security+
Oracle Certification: OCP 9i, OCP 10g, OCA 9i, OCA 10g CIW foundation    EC-212-32    CISSP    Photoshop ACE    Adobe Flash ACE
© 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.