错误:不兼容的类型:字符串无法转换为char opp = JOptionPane.showInputDialog(" Enter Method");

时间:2018-03-31 09:12:53

标签: java

我正在添加一个代码,这给出了以下错误:

  

//在对话框中打印导入javax.swing.JOptionPane;

<VirtualHost *:80>
     ServerName xserver.dev
     DocumentRoot /var/www/xserver/public
     SetEnv APPLICATION_ENV "development"
     <Directory /var/www/xserver/public>
         DirectoryIndex index.php
         AllowOverride All
         Require all granted
     </Directory>
     ErrorLog ${APACHE_LOG_DIR}/xx-error.log
     CustomLog ${APACHE_LOG_DIR}/xx-access.log combined
 </VirtualHost>

错误

  

ExampleWorking1.java:21:错误:不兼容的类型:字符串无法转换为char

     

opp = JOptionPane.showInputDialog(&#34;输入方法&#34;);

     

1错误

1 个答案:

答案 0 :(得分:0)

您的代码存在问题,即您有多个编译错误,虽然它们都不对应您添加的错误消息,但修复它们可以解决您的问题。

  • 您的变量use属于boolean类型,但您尝试为其分配String,这是不兼容的类型,并且您的案件。您不需要boolean变量来存储符号。

  • 在所有if语句中,您使用的是运算符=,它用于为变量赋值而不用于比较(有关分配值的详细信息,请参阅{ {3}})。如果您想比较值,则应==使用equalsString使用use方法 - 您可以看到this tutorial的原因。

修复错误类型的if变量并对数据类型使用正确的比较而不是在const server = require('http').createServer(); const io = require('socket.io')(server); io.on('connection', (socket) => { console.log('A user connected!'); io.emit('welcome', 'Hello there!'); }); server.listen(3001); console.log('Socket server started on port 3001'); 条件内重新分配变量值后,您的代码将正常运行。