你定义的sex是char类型,不是String类型,
这是javaapi文档中对next()方法的解释,返回的是一个String类型
public String next(String pattern)
Returns the next token if it matches the pattern constructed from the specified string. If the match is successful, the scanner advances past the input that matched the pattern.
An invocation of this method of the form next(pattern) behaves in exactly the same way as the invocation next(Pattern.compile(pattern)).
Parameters:
pattern - a string specifying the pattern to scan
Returns:
the next token
Throws:
NoSuchElementException - if no such tokens are available
IllegalStateException - if this scanner is closed