问题标签 [main-method]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c# - 如何将 C# 程序的起点更改为另一种方法?
我知道我们可以有很多 Main 方法的重载并且有不同的方法。但是要运行 C# 类,类应该有 main() 方法,签名为 public static void main(String[] args){} 如果对此签名进行任何修改,编译将成功。但是,由于找不到主要方法,您将收到运行时错误。我有两个问题。
- 如何将 C# 程序的起点更改为另一个方法(包括 Main 方法的任何重载)?
选择运行的默认类是什么?我们能改吗??
公共静态无效主要(字符串[]参数){}
floating-point - 为什么 getFloat() 中的浮点值变为 0.0?
我是java新手,我的浮点编码有什么问题吗?因为它变成了 0.0 而我不太了解 float 你能解释一下吗?它发生在 getFloat
这个程序计算锥体体积
该程序用于 Cone_Volume 的主要方法
输出:
java - 如何从命令行运行 Java Gradle 项目中的 main 方法?
我有一个 Gradle 项目(例如MyProject
),它有一个我只想用来运行小型 Java 应用程序的 main 方法。说,脚本在一个类和包中,如下所示:
MyScript.Java
我用 构建项目$ ./gradlew clean build
,没问题。我正在尝试通过命令行运行它,但是当我这样做时,尝试运行时出现异常:
这个脚本不是应用程序的主要部分,但我只是希望它在那里每隔一段时间运行一次,我想弄清楚如何通过命令行自行运行它。有没有办法在不导入库的情况下做到这一点?我见过用一个罐子做的,但我想我可以不用一个罐子做这个。
更新:
阅读此内容后尝试添加类路径,但现在我遇到了不同的错误:
java - Java SE 中的控制器类是什么?
有人可以解释 Java 中控制器类的含义和位置吗?为什么我们需要把 main 方法放在那里?
java - 从 Java Main 方法在 Firebase 上保存数据不起作用
我正在尝试使用 main 方法将 Java 类中的数据保存在 Firebase 上。但它不起作用。
我阅读了很多帖子,但我无法找到解决方案。
我的代码是:
更新:
如果我尝试使用此代码:
代码抛出此错误:
有人建议?帮助?
问候
埃米利亚诺
python - How to call my_function in main & prompt user for input in main method; my_function accepts user input & concatenates in reverse order (Python 3)
I need to create a function that does the following for a class assignment: - Write a Python function that will accept as input three string values from a user. The method will return to the user a concatenation of the string values in reverse order. The function is to be called from the main method. - In the main method, prompt the user for the three strings.
Originally, I had created a function (lkng_glss_lttr_bot) with a nested dictionary that would prompt the user for input (sections of a letter), store it in the dictionary, concatenate the entries and then return the reverse-ordered strings as a Looking Glass Letter of sorts. The function worked the way that I expected it to, and I was able to create a small program with loops so that the user could keep adding more entries. But once I added the main method, removed the input from lkng_glss_lttr_bot() and tried to put the input into main(), everything went haywire.
Currently, I'm getting NameError: name 'recipient' is not defined. If I comment out the get_recipient() function, then it goes on to the next nested function and gives me a NameError.
I'm missing something in my code that is allowing the variables to be named - but I'm a noob and I can't figure out where the issue lies.
I thought possibly the nested dictionary was the problem, so I simplified the function by taking out the dictionary, removing the loops, and terminating the program after one letter was composed. Again, the function worked while the input was in lkng_glss_lttr_bot(), but once I tried to put the input into main(), I couldn't get the program to execute.
The examples I've seen on SO suggest creating a separate function outside of main() to store info and have the user input in that separate function, but this won't work for the requirements of my assignment. Some people also suggested adding global variables. I tried that, and still received the same error.
I tried creating nested function for each variable, and returning the variable, but that also didn't work. I thought that nesting the functions within main would meet the requirements of having the user input in the main method, but I'm still getting a NameError.
I honestly don't understand main() at all, especially with user input because the examples I've seen don't have the input in main().
The letter should look like this:
,aloL tseraeD yM
.enif m'I ?uoy era woH
!uoy ssim I
,noitceffa dna evol ym lla htiW
oG-oG
!em llaC .S.P
And everything works as I expect it to if the input prompts are in the lkng_glss_lttr_bot function. But I can't wrap my head around main(). Any suggestions to get me in the right direction would be appreciated. Thanks!
unit-testing - Intellij:如何在文件夹中运行所有 main() 方法?
在 IntelliJ 中有一个功能可以在一个文件夹中运行所有单元测试。是否有可能以相同的方式运行所有 main() 方法?
c# - 构造函数和主要方法有什么区别?
我使用 C# 已经有一段时间了,但主要是在 Unity 中。我最近才开始在 Visual Studio 中简单地编写 C# 代码。
我只是在玩用数组实现队列,并对构造函数进行了一些研究。在我的 Queue 类中,我有一个构造函数,它为数组本身设置了一个实例:
然后在调用创建队列并使用它进行一些测试等的类中,我使用了一个主要方法:
现在我的问题是这两种方法有什么区别?目前对我来说,它们只是“程序最初运行时调用的方法”,有点像Start()
我习惯的 Unity 中的方法。
java - 如何修复主要方法?
如何解决此问题:在 jamel.Jamel 类中找不到主方法,请将主方法定义为:public static void main(String[] args) 在此处输入图像描述
java - 从不同的类调用方法引发“在类 com.company.UniLink 中找不到主方法”错误
我正在开发这个基于控制台的应用程序。它基本上是一个大学系统,学生可以在上面发布不同类型的帖子,人们可以回复那里的帖子。
所以,我有这个启动课
我正在使用一个名为 Unilink 的类,它正在完成所有繁重的工作并运行整个程序。我这样做是为了更好地封装和更清晰地展示代码。我的菜单类允许执行以下任务。
但我一直收到这个错误
我喜欢任何帮助