This week's book giveaways are in the Jython/Python and Object-Oriented programming forums.
We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Am i right or wrong ?

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am i right or wrong ?

Any primitive value, +ve or -ve of byte, short, int, long, float and double CAN be converted to char.
String CANNOT be converted to char.
And
Any Wrapper object, +ve or -ve of Byte, Short, Integer, Long, Float and Double CANNOT be converted to Character object.
String CANNOT be converted to Character.

Reply
[ March 01, 2007: Message edited by: Pankaja Shinde ]
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends what you mean by "converted." If you mean "cast", then yes, I suppose you're correct. But there are other ways to "convert" things (constructing new objects, calling methods like "toString()" and "valueOf", etc.)
 
Pankaja Shinde
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, i mean casting any primitive value to char.
 
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not only Byte, Short, Integer, Long, Float and Double CANNOT be cast to Character they CANNOT be cast to each other either.

It is curious that Byte, Short, Integer, Long, Float and Double can be cast to Number but Character cannot be.
 
Pankaja Shinde
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Byte, Short, Integer, Long, Float and Double CANNOT be cast to each other because they are peer classes.

Byte, Short, Integer, Long, Float and Double extends Number Class, therefore they can be cast to Number, But Character and Number classes are peer classes. Therefore they cannot be cast to each other.

See the Inheritance Hierarchy of java.lang package.
 
I wasn't selected to go to mars. This tiny ad got in ahead of me:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!