• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

insertion operator

 
prashantK Singh
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all
kindly somebody elaborate me the result of the program

class EBH007{
public static void main (String[] s) {
byte b = 5; System.out.println(b<<1);
}}
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The left-shift operator will move all of the bits over by 1 position, so the result is going to be

00000000000000000000000000001010
 
wise owen
Ranch Hand
Posts: 2023
 
prashantK Singh
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello
it is showing the output as 10
and not 1010
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The binary representation of 10 is 1010. What I showed is the bit string that is produced.
 
prashantK Singh
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you Keith
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic