• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Small Doubt

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic