命令行参数. [英] command line arguments.

查看:102
本文介绍了命令行参数.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是初学者,我想在 netbeans 中传递一个字符串作为命令行参数.我该怎么做?谢谢

I am beginner and I want to pass a string as a command line argument in netbeans .how can i do this? thanks

推荐答案

在可以接受命令行参数的标准 Java 程序中,会有一个类作为整个程序的入口点.该类将有一个静态方法,如下所示:

In a standard Java program that can take command line arguments, there will be a class that acts as the entry point of the whole program. That class will have a static method in it like this:

public class FooBar {
    // ...
    public static void main(String[] arguments) {
        // ...
    }
    // ...
}

参数位于作为该方法参数的数组中,该数组必须具有该签名并且既是公共的又是静态的.如果您使用的是托管引擎或框架,通常会为您处理入口点;您应该查阅其文档以了解如何获取命令行参数(如果可能的话,甚至是合理的).

The arguments are in the array that is the parameter to that method, which must have that signature and be both public and static. If you're using a hosting engine or framework, the entry point is often taken care of for you; you should consult its documentation to see how to get command line arguments (if that is possible at all, or even reasonable).

命令行参数总是字符串.如果你想将它们解释为别的东西,你必须手动转换它们.

Command line arguments are always strings. If you want to interpret them as something else, you've got to convert them manually.

这篇关于命令行参数.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆