Add 0b in front of your long one to say that it is a binary number.
long whitePieces = 0b0000000000000000000000000000000000000000000000001111111111111111L; ^^
Prefix
( 0b was introduced in Java 7. If you are using an older version, you can do Long.parseLong("000...111", 2) )
Another approach: how about creating an enumeration:
enum ChessPiece { Pawn, Knight, ... };
and save the board in ChessPiece[8][8] . This should provide you with a cleaner interface for reading and changing state than the long message gives you.
If you are concerned about performance, just keep the actual view properly encapsulated in the Board class (make the actual data structure private). If you later find that ChessPiece[8][8] is a bottleneck, you can play around and effortlessly change it to long .
source share