Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class C
- {
- public static void myPrint(String ... names)
- {
- for (String n : names)
- {
- System.out.print(n);
- }
- }
- public static void main(String[]args)
- {
- myPrint();
- myPrint("A");
- myPrint("A" , "B");
- myPrint("A" , "B" , "C");
- // OPCJA 1
- //A <String>a = new A<String>("jas"); //constructor A in class A<T> cannot be applied to given types
- //A <int>b = new A<String>(1); //unexpected type
- //A <Double>c = new A<Double>(1.1); //constructor A in class A<T> cannot be applied to given types
- //A <double>d = new A<double>(1.1); //unexpected type
- //A <int>e = new A<int>(1); //unexpected type
- A <String>a = new A<String>("jas");
- //A <int>b = new A<String>(1); //unexpected type
- A <Double>c = new A<Double>(1.1);
- //A <double>d = new A<double>(1.1); //unexpected type
- //A <int>e = new A<int>(1); //unexpected type
- }
- }
- // OPCJA 1
- //class A<T>{ }
- //OPCJA 2
- class A<T>{
- T t;
- public A(T a)
- {
- t = a;
- System.out.println(t);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement