字符串不能转换为字符,如何解决它?

字符串不能转换为字符,如何解决它?

问题描述:

它说“不兼容的类型:字符串不能转换为字符” 如何解决它? 这里是例子。 code as image字符串不能转换为字符,如何解决它?

+1

宣布你们CHAR是作为字符串。 –

+0

我强烈建议您先阅读基础知识 –

+0

如何将其声明为字符串?我是初学者 –

这是您的解决方案:

public class NewMain { 
    public static void main(String args[]) throws ParseException { 
     Scanner s = new Scanner(System.in); 
     char yes; 
     do { 
      System.out.println("Hi"); 
      yes = s.next().charAt(0); 
     } while (yes == 'Y'); // if u enter 'Y' the it will continue 

    } 
} 

要退出进入其他任何东西,然后'Y'

+0

好的,谢谢 –