• 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

Byte upgraded to float?

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
please have a look over the following code, and tell me why the Byte type variable is also being upgraded to Float type while calling as a function argument? The Integer variable is understandably upgraded to Float, but why Byte, even when the definition of function with Byte argument is available?



------------------
Manish.
 
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure but I'd say it's because you're using Byte as the incoming parameter type in the method. The initial variable is a byte, not a Byte. There is nothing in Java to automatically cast a byte type to a Byte object.
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Manish,
Paul is correct. Primitives are never converted to objects or vice-versa. The relevant documentation can be found at:
http://java.sun.com/docs/books/vmspec/2nd-edition/html/Concepts.doc.html#25611
------------------
Brett Spell
Author, Professional Java Programming
 
Manish Malik
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paul Keohan:
I'm not sure but I'd say it's because you're using Byte as the incoming parameter type in the method. The initial variable is a byte, not a Byte. There is nothing in Java to automatically cast a byte type to a Byte object.


Thanks. :-)


------------------
Manish.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic