• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AutoBoxing&generic

 
kishor kalapa
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
In this code I am geting error at Line1,if I make Line1 as comment and remove Line2 comment program running sucessfully,Can any one explain the why Line1 not working,

class useme<T,X,Y>
{
private T T1 ;
private X X1;
private Y Y1;
useme(T a,X b,Y c)
{
this.T1=a;
this.X1=b;
this.Y1=c;
}
X retX ()
{

return X1;
}
Y retY ()
{

return Y1;
}
T retT()
{

return T1;
}
}
class Test
{
public static void main(String[] arg)
{

useme<Integer, Float,Character> us=new useme<Integer, Float,Character>(11,1.2,'a'); //line1
//useme<Integer, Float,Character> us=new useme<Integer, Float,Character>(new Integer(11),new Float(12),new Character('a'));//line2

System.out.println(" "+us.retX()+us.retY()+us.retT());
}

}
 
Bhavik patel
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Kishor,

the second parameter you are pssing at line1 is 1.2 and it will be considered as double , in fact required type is short or Short, means at line1 pass 1.2f
[ June 24, 2008: Message edited by: Bhavik patel ]
 
kishor kalapa
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hellow Bhavik
Now my program is compile sucessfully,but I not getting in reply
you mention "short or SHORT as required" please explain meaning behand that,
Thanks for reply.
 
Bhavik patel
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Kishor,

Sory for my mistake...read "short or Short" as "float or Float" in my previous post.

Sorry again..
 
kishor kalapa
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks again for reply
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic