Revision: 63707
Updated Code
at May 31, 2013 12:34 by borysn
Updated Code
private List<Character> initCharacterList(int numberOfCharacters, int asciiStart, int asciiEnd) { // first ensure ascii table values assertTrue("asciiStart is invalid", asciiStart >= 0 && asciiStart < asciiEnd); assertTrue("asciiEnd is invalid", asciiEnd <= 127 && asciiEnd > asciiStart); List<Character> list = new ArrayList<>(); int asciiPos = asciiStart; for (int i = 0; i < numberOfCharacters; i++) { Character c = new Character((char)asciiPos); list.add(c); asciiPos++; if (asciiPos > asciiEnd) { asciiPos = asciiStart; } } Collections.sort(list); return list; }
Revision: 63706
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 31, 2013 11:00 by borysn
Initial Code
private List<Character> initCharacterList(int numberOfCharacters) { List<Character> list = new ArrayList<>(); int asciiStartPos = 33; int asciiEndPos = 126; int asciiPos = asciiStartPos; for (int i = 0; i < numberOfCharacters; i++) { Character c = new Character((char)asciiPos); list.add(c); asciiPos++; if (asciiPos > asciiEndPos) { asciiPos = asciiStartPos; } } Collections.sort(list); return list; }
Initial URL
Initial Description
FIll a List<Character> with ASCII (0-127) characters with a given number of characters.
Initial Title
Fill Character List From ASCII Table And Sort
Initial Tags
list, java
Initial Language
Java