Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
javaで16桁の乱数を作りたいです。私は String でそれを行うことができ、その後 Long に変換します。他のオプションはありますか?
ありがとう!
絶対に16桁が必要な場合(0から10 ^ 17-1の数字ではありません)
Random rand = new Random; long accumulator = 1 + rand.nextInt(9); // ensures that the 16th digit isn't 0 for(int i = 0; i < 15; i++) { accumulator *= 10L; accumulator += rand.nextint(10); }
i < 16必要に応じて使用してください。
i < 16