Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

primitive data types??

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pl. suggest,
int I=90;
char c=I; //cating required, agreed . . .
final int ii =90;
char c=ii; // casting not req. , agreed ,will
// compile . . .
char f=65;
char x=f ; // compiles, agreed . . .
// char x=f >> 1; // not compiling . . . WHY?
Problem :
Why this is not compiling -
char x =f >> 1;
What I am assuming is that var. f will hold any value within the range Of character , therefore when we say - char x=f, codes get
Compiled.But why - char x=f >> 1; will not compile where
Signed right shift ( >> ) will always reduce the value of
Var. f & it will always remain within the range of characters.

Thanks,
Vikas
 
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
char f=65;
char x=f ; // compiles, agreed . . .
// char x=f >> 1; // not compiling . . . WHY?
I'll try to explain, char f= 65 is fine it's promoted to be an int value so later when you try to do an operation on it , it will require you to cast bacause it's an int value. Any further operation on it must be cast it
even if you had this
char x = f + 1;
 
vikas singh
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanx valdra,
the explanation was very simple & to the point.
It made me clear my doubt.
Vikas.
 
Val Dra
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
your welcome
 
We can walk to school together. And we can both read this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic