I have written a method which is supposed to get a string from the console and turn it into a char array, but it only returns gibberish, I can't see the problem either.
Code:
public static char[] readchararray()
{
BufferedReader dataIn = new BufferedReader( new InputStreamReader(System.in));
String temp = "";
int length = 1;
char[] tempchar = new char[1];
try
{
temp = dataIn.readLine();
tempchar = temp.toCharArray();
}
catch(IOException e)
{
System.out.println("Error in reading input");
}
return tempchar;
}
Comment