• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Small Doubt

 
ramap prabhas
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class A2 {
public static void main (String args[]) {
byte primitiveByte = 1;
int primitiveInt = 1;
long primitiveLong = 1L;
float primitiveFloat = 1f;
String s = "1";
Long i1 = new Long(primitiveByte);
Long i2 = new Long(primitiveInt);
Long i3 = new Long(primitiveLong);
Long i4 = new Long(primitiveFloat);//
Long i5 = new Long(s);
int i6 = i1.intValue() + i2.intValue() +
i3.intValue() +
i5.intValue();
System.out.print(i6);
float i7 =i4.floatValue();
System.out.println(i7);
}}
Long has two constructors: one accepts an argument of type primitive long; the other accepts an argument of type String.Here The class instance creation expression new Long(primitiveFloat) generates a compile-time error.
My doubt is, Long could accept upto 64bits value, then why it is not accepting float(32 bits) values.
Regards,
Rama
 
ramap prabhas
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of posting my query in the Programmer Certification. My mistake i posted it here. I am sorry for that.
Regards,
Rama
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic