简体   繁体   English

为什么我不能在方法中添加更多然后这个参数

[英]Why cant i add more then this one parameter to the method

Im using JavaFX since a couple of days, so the code im complaining with is just copy pasted (its only one line though ;)) and i dont know why i cant add more than this one prameter to the method.我已经使用 JavaFX 几天了,所以我抱怨的代码只是复制粘贴的(虽然它只有一行 ;)),我不知道为什么我不能在方法中添加不止这一个参数。

first picture第一张照片

when i only write args to the parameters its working.当我只将 args 写入其工作参数时。 Here's the Method i want to use:这是我想使用的方法:

enter image description here在此处输入图片说明

Sorry for my bad english and thank you for the help,抱歉我的英语不好,谢谢你的帮助,

IDEsAreTheBest IDE 是最好的

This is because launch(args);这是因为launch(args); is a "predefined" JavaFX method, located in an abstract class.是一个“预定义的”JavaFX 方法,位于抽象类中。

Take a look at the following:看看以下内容:
As you can see, the method only accepts one argument.如您所见,该方法只接受一个参数。

public static void launch(String... var0) {
      // Heres the logic
}

To Fix that, you could do the following:要解决此问题,您可以执行以下操作:

  1. Declare your Map<String, String> outside of your main()在 main() 之外声明Map<String, String>
  2. Only initialize it in your main method只在你的主方法中初始化它
  3. Access it via this.userInformation in your start-method通过 start-method 中的 this.userInformation 访问它
    To visualize everything, heres some code为了可视化一切,这里有一些代码
public class Gui {

   private static Map<String, String> userInformation;

   public static void main(String[] args) {
      
      // All the other logic
      userIformation = scanDocument(file);
      launch(args);
   }

   public static void start(Stage primaryStage) {
      
      // All the other logic
      // Here you can access your Map<> by
      // simply using userInformation.blablabla();
   
}

I hope this helped you a at least a little bit.我希望这至少对您有所帮助。

And also... Please never use german words or none of the english letters (like öäü) in variablenames...还有...请不要在变量名中使用德语单词或任何英文字母(如 öäü)...

Sidenote: Uhrzeitmacher?旁注:Uhrzeitmacher?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM