The fill() method in the Arrays class is useful for creating string filled with a certain character.
// create a buffer of 9 characters
char[] fill = new char[9];
// Fill the buffer with all '0's
Arrays.fill(fill, '0');
// Create string using the buffer
String zeroes = new String(fill);
// zeroes string now contains "000000000"
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment