This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of TensorFlow 2.0 in Action and have Thushan Ganegedara on-line!
See this thread for details.
Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning 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
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Casting Problem

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
byte b = 100+10;
is this is a correct assignment. If yes then why?
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Intizam
Integer has been assigned to byte which is narrowing of conversion. But the narrowing of conversion is taking place within the range of byte which is -128 to 127 and hence should work fine.
Hope this explains.
Regards
Sandip
 
Ranch Hand
Posts: 1874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Intizam , Welcome to javaranch.
PROPER NAMES ARE NOW REQUIRED
Please look carefully at official naming policy at javaranch & reregister yourself with proper first & last name. Please adhere to official naming policy & help maintain the decorum of the forum.
Waiting for your posts with proper first & last name. Once you have reregister , please let us know about that & then your previous account will be disabled.
Regards.

Your Friendly Bartender
Shailesh.
 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Integer LITERALS can be assigned to byte, short and char if the interger LITERALS are within the range of byte, short and char.
100+10=110, 110 is an integer literal and within the range of byte (-128 -- 127), so it can be assigned to byte type variable b.
 
Good night. Drive safely. Here's a tiny ad for the road:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic