Aug 25

The Integer class contains a number of (static) methods for converting to/from various formats. To convert to an integer use static method Integer.parseInt()

String s = "123";
try
{
   int i = Integer.parseInt(s);
}
catch (NumberFormatException ex)
{
   // s is not an integer
}

written by objects \\ tags: , , ,

Aug 23

By simply casting the int value to a char.


int asciiValue = 65;
char ch = (char) asciiValue; 

written by objects \\ tags: , ,