Monday, June 30, 2014

Generics Part 2

package Generics;

import java.math.BigDecimal;

import org.junit.Test;

class GenericsTest<T > {
private T t;

GenericsTest(T t) {
this.t = t;
}

void Method(String test) {
if (t.equals(test)) {
System.out.println("iiiiiiiiiiiii");

}

}

}
class GenericsTest1 <T extends Object > {
private T t;

GenericsTest1(T t) {
this.t = t;
}

void Method(String test) {
if (t.equals(test)) {
System.out.println("iiiiiiiiiiiii");

}

}

}

public class Generics {
@Test
public void M1(){
GenericsTest<BigDecimal> generics = new GenericsTest<BigDecimal>(new BigDecimal(0));
generics.Method("test");

}

}

No comments:

Post a Comment