为什么此语句错误显示“无法将字符串转换为组件”?

时间:2018-08-01 18:28:57

标签: java

JOptionPane.showMessageDialog("#1", "#2", "Total", "Result");

试图显示创建结果的显示,但是我得到了以下说法的错误:“字符串无法转换为组件。

1 个答案:

答案 0 :(得分:0)

该方法的第一个参数是using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; using System.Numerics; namespace Tarea_4_Programa_1 { // Formula = n^2 - 100n + 900 class Program { static void Main(string[] args) { double n = 1; // n in n^2 - 100n + 900 double y = 0; // result of the formula double firstchange =0; // first change of sign double secondchange = 0; //second change of sign // Iterates the formula n^2 - 100n + 900 with n = 1 to 1000 for (int i = 0; i <=1000; i++) { y = Math.Pow(n, 2) - 100*n + 900; n = n + 1; if (y < 0) { firstchange = n; } else if (y > 0) { secondchange = n; } Console.WriteLine("When n is " + (n - 1)+ " the result is " + y); } Console.WriteLine("------------------------------------------------------"); Console.WriteLine("When n is " + firstchange + " result becomes negative"); Console.WriteLine("When n is " + secondchange + "result becomes positive"); Console.ReadLine(); } } }

Component

您传递的是 showMessageDialog(Component parentComponent, Object message, String title, int messageType) (#1),而不是String