문제

I want to save a very large number like 111111111100000001010 in an ArrayList in java. After saving I should be able to find the number of bytes needed to save it. The number is found using a function String Find_code(int input). How can I efficiently save it in memory? For example 21 bits for 111111111100000001010.

도움이 되었습니까?

해결책

Use a BitSet.

This class implements a vector of bits that grows as needed. Each component of the bit set has a boolean value. Individual indexed bits can be examined, set, or cleared.

다른 팁

If 111111111100000001010 is a binary number, then it will fit in an integer. Simply store it in an array list of integers ArrayList<Integer>.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top