Hi,
Below code returns ?
rather than a random character. Any ideas? Please note that i wrote this as pat of an exercise on method overloading hence the 'complicated' setup.
class TestRandomCharacter
{
public static void main(String[] args)
{
char ch = RandomCharacter.getRandomCharacter() ;
System.out.println(ch);
}//end main
}
class RandomCharacter
{
public static char getRandomCharacter(char ch1, char ch2)
{
return (char)(ch1 + Math.random() * ( ch2 - ch1 )) ;
}
public static char getRandomCharacter()
{
return getRandomCharacter('\u0000','\uFFFF') ;
}
}