public static String doCensor(String toCensor)
{
Object[] aobj;
int l = (aobj = toCensor.toCharArray()).length; //THIS LINE OF CODE IS THE PROBLEM
The reason I want to convert it to an object is so I can cast to either a specific character or string later. Is there any easier way to do this?
Casting examples:
char c = (char) aobj[j];
String word = (String) aobj[k];
The right way to do this is just to get the
char[]fromtoCharArray, and then if you need aString, useCharacter.toString(char). You cannot cast acharto aString.