my dog learned polymorphism
The moose likes Java in General and the fly likes What are Wildcards? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "What are Wildcards?" Watch "What are Wildcards?" New topic
Author

What are Wildcards?

Umesh Kilkile
Greenhorn

Joined: Mar 31, 2010
Posts: 11
Hi,

Explain me simple words or
Please suggest me any good site,where I can learn Wildcards.

Thank You,

Umesh K
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

a wildcard represents something unknown or undefined.
As a basic example we use '?' to represent a single character and '*' to represents zero or more characters
So test?.txt matches test1.txt testA.txt but not test.txt or testAB.txt
test*.txt matches everything test?.txt matches and a bunch more.

Learn by doing. Regular Expressions are all about matching patterns and make extensive use of wildcards.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 44563
    
  34
Whihch wildcards? You get wildcards (as David O'M has already told you) in regular expressions, and also in actual type parameters for generics. Probably elsewhere too.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

but in a general sense both represent "something unknown or undefined"
eg List<T> is a "List of something"
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3719
    
  61

eg List<T> is a "List of something"

Just to clarify, I don't think this is an example of wildcard. T in this case is a type parameter. Wildcard would be the question mark in List<?>.
Umesh Kilkile
Greenhorn

Joined: Mar 31, 2010
Posts: 11
Hi,

Actually I wanted to learn using wildcards in Java and in Generics.

Please help me.

Thank You,

Umesh
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3719
    
  61

Try this one. It is the Sun's (now Oracle's) own tutorial.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What are Wildcards?
 
jQuery in Action, 3rd edition