Results 1 to 6 of 6
  1. #1
    ajt
    ajt is offline Member
    Join Date
    Jan 2012
    Posts
    2
    Rep Power
    0

    Default Java bitwise error

    Hi there,

    I have this code
    Java Code:
    import static java.lang.Long.*;
    public class bit {
    public static void main(String[] args) {
    long number = 0xF000_0000_0000_000FL;
    System.out.println(number);
    }
    }
    I get this compile error:

    bit.java:4: ';' expected
    long number = 0xF000_0000_0000_000FL;

    Are the _ underscores just used in the examples to make it easier to read what is going on? Or are they used in code and something is wrong with my setup? I am running Ubuntu 11 and JDK 6

    java version "1.6.0_23"
    OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre11-0ubuntu1.11.10)
    OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)


    Thanks,
    Ajt

  2. #2
    eRaaaa is online now Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    5

    Default Re: Java bitwise error

    The code is correct, but works only in Java 7 !

  3. #3
    Join Date
    Sep 2011
    Location
    Mumbai, India
    Posts
    35
    Rep Power
    0

    Default Re: Java bitwise error

    According to me the problem is underscore. How can we insert underscores between numbers and store them in an numerical data type like long.

    So remove the underscore.

  4. #4
    eRaaaa is online now Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    5

    Default Re: Java bitwise error

    Quote Originally Posted by Rameshwar Soni View Post
    According to me the problem is underscore. How can we insert underscores between numbers and store them in an numerical data type like long.

    So remove the underscore.
    Underscores in Numeric Literals

  5. #5
    Join Date
    Sep 2011
    Location
    Mumbai, India
    Posts
    35
    Rep Power
    0

    Default Re: Java bitwise error

    Sorry once again i never knew this was possible in Java 7.

    @eRaaaa : Thanks

  6. #6
    ajt
    ajt is offline Member
    Join Date
    Jan 2012
    Posts
    2
    Rep Power
    0

    Default Re: Java bitwise error

    Thank you both for the quick reply. I hope you have a great day.

Similar Threads

  1. Feeling a lil bitstupid with this bitwise.
    By demitrix in forum New To Java
    Replies: 19
    Last Post: 07-06-2011, 08:11 AM
  2. help me in simple Bitwise operator :(
    By funkygarzon in forum New To Java
    Replies: 3
    Last Post: 08-13-2010, 10:48 AM
  3. bitwise not ~ operator
    By kezkez in forum New To Java
    Replies: 2
    Last Post: 02-10-2010, 06:49 AM
  4. Bitwise operations with long
    By NewJavaBean in forum New To Java
    Replies: 2
    Last Post: 04-07-2009, 07:37 PM
  5. Using the bitwise operators
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 07:39 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
  •