This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
There does not seem to be an easy way to take an int (like a 32) and return its character representative ( a Space). I looked through the Integer and Character classes along with some other help topics. This seems so simple but I cannot find the answer. Thanks Kelly Harris
Just reiterating that the method mentioned in the second post will not work as you are trying to cast an object (Integer) into a simple type (char). This should throw a compile time exception. The method mentioned in the third post is correct - directtly cast from simple type (int) to simple type (char).
Of course if you really want it to be a string you could always use String myString = myInt + "";
The Eagle sneers at the Peacock<p>Systems Administrator<br />OrderWare Solutions Ltd<br /><a href="http://www.orderware.net" target="_blank" rel="nofollow">http://www.orderware.net</a>
One thing to note about casting chars and other primitives. The following code is legal because a char (2 bytes) is smaller than an int (4 bytes), therefore a windening conversion is taking place and an implicit cast is done.
However, the following code is illegal, even though both data types are 2 bytes.
The reason this is illegal is because the data type char, unlike other primitive types (boolean and void excluded), is unsigned. Therefore, the range of a char does not exactly match the range of a short (and vice versa). Just something to keep in mind. Corey