posted 17 years ago
Try to think about the two thinks completly separated one from another:
One is defining a class Tester, the other defining a variable of type Tester
When defining a class like
you declair that every instance of this class will have to have 2 parameters (of cause you can leave the parameters at all, but if paramters are used...).
The first has to be whatever the implementer wants.
The second has to extend Number , so could be Integer or Long or...
This guarantees that Methods of tester are acting only on Number-Instances, not e.g. on Strings..
If than someone instantiates your class
she is doing 3 things:
a) declair a variable named teste.
This can hold every Teste-object which has parameters String ans Something superior to number.
b) create a new Teste-Object with Parameters String and Number
c) assign the object to the variable
Due to your class-definition the object could also be a
new Teste<Integer,Integer>()
but you would not be able to assign to the variable.
On the other hand, later inb the program, you could instantiate another tester-object eg (new Tester<String,Integer>()) and assign to your variabe tester.
This is ok cause Integer is "super" to Integer.
Other Instance-types are not possibel to assign to tester,because
var 1 has to be a String and
var 2 has to be super to Integer and extending Number and this is true only for Number and Integer
Hope this helps
========<br />class a{<br /> a a(a a){return (a)a;}<br />}