intermediate/GenericExample

From ggc

Jump to: navigation, search

01 package intermediate;
02 
03 
04 /**
05  * All about my application.
06  @author My Name Here
07  */
08 public class GenericExample<S,T extends Number>
09 {
10   private T t;
11   private S s;
12 
13   public void setValue(T t)
14   {
15     this.t=t;
16   }
17 
18   public T getValue()
19   {
20     return t;
21   }
22 
23   public void setKey(S s)
24   {
25     this.s=s;
26   }
27 
28   public S getKey()
29   {
30     return s;
31   }
32 
33   public String toString()
34   {
35     return "key="+s+", value="+t;
36   }
37 
38   public static void main(String[] args)
39   {
40     GenericExample<StringDouble> example=new GenericExample<StringDouble>();
41     example.setKey("Howdy!");
42     example.setValue(4.5);
43     System.out.println(example);
44   }
45 }


Download/View intermediate/GenericExample.java





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter