I have to select and return 1 random character out of a string using this method (separate from main method):
public static char selectAChar(String s)
I'm not sure how to select the random variable, and not sure if i should use a for loop. everything I've tried I couldn't get it to return the right variable type.
EDIT: heres the coding i have so far
public static void main(String args[])
{
Scanner kbd = new Scanner (System.in);
System.out.println("Enter a string: ");
String s = kbd.next();
selectAChar(s);
}
public static char selectAChar(String s)
{
}
i tried something using this for loop for(int i = 0; i < s.length(); i++) but i can't figure out how to choose a random character and return it.