+ Reply to Thread
Results 1 to 3 of 3

Thread: What does "<<" mean in Java??

  1. #1
    rebolli is offline x10Hosting Member rebolli is an unknown quantity at this point
    Join Date
    Mar 2010
    Posts
    3

    What does "<<" mean in Java??

    Hello,

    Could anyone tell me what the syntax "<<" does in java?
    For example, if I do the operation 1 << 4 I'll get the output 16. How does that work?

    Couldn't find this on google cause the characters "<<" are ignored..

  2. #2
    essellar's Avatar
    essellar is online now Community Advocate essellar has a spectacular aura about
    Join Date
    Feb 2010
    Location
    Toronto, Ontario, CA
    Posts
    1,152

    Re: What does "<<" mean in Java??

    It's a bitwise left shift. In your example, you start out with a one, which can be represented in binary as: 00000000 00000001

    then you tell the computer to shift the bits leftwards four times, yielding this binary number: 00000000 00010000

    10000 in binary is 16 in decimal.
    “Beware of bugs in the above code; I have only proved it correct, not tried it.” --Donald Knuth
    "It was as if its architects were given a perfectly good hammer and gleefully replied, 'neat! With this hammer, we can build a tool that can pound in nails.'" -- Alex Papadimoulis (on TheDailyWTF.com)

  3. #3
    rebolli is offline x10Hosting Member rebolli is an unknown quantity at this point
    Join Date
    Mar 2010
    Posts
    3

    Re: What does "<<" mean in Java??

    Ah okay! Thank you!

+ Reply to Thread

Similar Threads

  1. Replies: 7
    Last Post: 10-01-2009, 05:16 PM
  2. Replies: 2
    Last Post: 11-30-2008, 04:49 PM
  3. login with header("WWW-Authenticate: Basic realm=\"example\"");
    By Jacob, Kid Mania Creator in forum Programming Help
    Replies: 2
    Last Post: 11-22-2008, 03:49 AM
  4. Transferencia de "Skyy" y "Ciroc" (Paid Servers)
    By ZharkD in forum Noticias y Anuncios
    Replies: 2
    Last Post: 11-19-2008, 10:12 PM
  5. Replies: 3
    Last Post: 11-28-2007, 05:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers