hex - Creating a string character by character in Java -
so have created program:
class input { public static void main(string[] args) throws exception { string hexa; hexa = ""; int pituus; pituus = hexa.length(); int = 1; char luku; char luku2; while (i < pituus) { luku = hexa.charat(i); luku2 = hexa.charat(i - 1); luku++; if (luku == 'g') { luku = '0'; luku2++; } else if (luku == ':') luku = 'a'; if (luku2 == '8') luku2 = '0'; system.out.print(luku2); system.out.print(luku); += 2; } system.out.println(); } } as can propably tell, prints original hex string, adds 1 every pair of characters, , want maximum value of pairs 7f. program beginning, , proceed further need string characters printed. possible?
to create strings dynamically can use stringbuilder. append characters like
stringbuilder sb = new stringbuilder();// builder empty // logic (char ch = 'a'; ch <= 'z'; ch++) { // example add lower-case // characters builder sb.append(ch); } // after characres placed in builder // lets convert string string alphabet = sb.tostring(); // , see got system.out.println(alphabet); output: dynamically generated alphabet
abcdefghijklmnopqrstuvwxyz
Comments
Post a Comment