File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 36476
    
  16
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: 3434
    
  47

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: 3434
    
  47

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?
 
Similar Threads
less time...what all to study and revise at last moment for exam?
K & B Mock exam Generics doubt
Strange prob with Library
wild card
Generics and collection