Please see the following code snippets:
1)
public Method getMethod(String name,
Class... parameterTypes)
throws NoSuchMethodException,
SecurityException
What is the meaning of ... after Class?
Does it indicate variable number of parameters?
But the method is supported Since JDK1.1.
2) Class c = String.class;
This is a code snippet from Reflection Java Tutorial.
From where .class comes? It is not a static field in String class.
Also it is not inherited from Object.
Nils Bandener - 18 Sep 2005 10:47 GMT
> public Method getMethod(String name,
> Class... parameterTypes)
[quoted text clipped - 3 lines]
> What is the meaning of ... after Class?
> Does it indicate variable number of parameters?
Yes, it does.
> But the method is supported Since JDK1.1.
Before Java 5, the method hat the signature (String name, Class []
parameterTypes). And in fact, Java 5 internally converts the arguments
given for the ellipsis parameter to an array containing these values.
So, the signatures mean the same.
> 2) Class c = String.class;
> This is a code snippet from Reflection Java Tutorial.
> From where .class comes? It is not a static field in String class.
> Also it is not inherited from Object.
.class is not a static field, but a special keyword that returns the
Class object of the particular class. So, the snippet above will give
you the class object for the String class.
Bye
Nils
Roedy Green - 18 Sep 2005 18:11 GMT
>public Method getMethod(String name,
> Class... parameterTypes)
It behaves just like
Class[] parameterTypes
except you can say
Dog.class, Cat.class, Rabbit.class
instead of
new Class[] { Dog.class, Cat.class, Rabbit.class }
when you invoke the method.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
Roedy Green - 18 Sep 2005 18:12 GMT
>2) Class c = String.class;
>This is a code snippet from Reflection Java Tutorial.
>From where .class comes? It is not a static field in String class.
>Also it is not inherited from Object.
see http://mindprod.com/jgloss/classforname.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.