MrGaribaldi
Posts: 2,488 +1
Hello
I've stumbled onto a problem on my latest assignment at the university, and hopefully someone can help me out...
The assignment says to create an array with 256 slots, which shall be filled with lists. The first node of each list shall be a char from the ascii table .
Now I know the first 32 entries on the ascii table are non-printing characters, and thus could be skipped, but the assignment calls for an array with 256 slots, so I want to fill them.
Now what my problem is:
How can I convert an int to a String with the corresponding ascii character?
Ie. "101" to "e", "173" to "¡".
I know that using the following code will convert from characters to the corresponding ascii number, but I can not fathom how to convert it back
(Also any streamlining of the above code will also be welcomed )
My plan is to use the integer value in the array (due to the first 32 characters) and use .charAt(0) (converted to integer using (some of) the above code) to see where in the array to search for the word).
I know by doing that I don't need to convert back to characters, but I'll need characters for a full printout of the array so....
Any help is appreciated!
TIA
I've stumbled onto a problem on my latest assignment at the university, and hopefully someone can help me out...
The assignment says to create an array with 256 slots, which shall be filled with lists. The first node of each list shall be a char from the ascii table .
Now I know the first 32 entries on the ascii table are non-printing characters, and thus could be skipped, but the assignment calls for an array with 256 slots, so I want to fill them.
Now what my problem is:
How can I convert an int to a String with the corresponding ascii character?
Ie. "101" to "e", "173" to "¡".
I know that using the following code will convert from characters to the corresponding ascii number, but I can not fathom how to convert it back
Code:
test = Integer.getInteger(readChar);
test = new Integer(readChar);
//can use either of the methods above
value = test.intValue();
(Also any streamlining of the above code will also be welcomed )
My plan is to use the integer value in the array (due to the first 32 characters) and use .charAt(0) (converted to integer using (some of) the above code) to see where in the array to search for the word).
I know by doing that I don't need to convert back to characters, but I'll need characters for a full printout of the array so....
Any help is appreciated!
TIA