zoukankan      html  css  js  c++  java
  • java命令行参数

    之前我们写的例子,main方法的参数里有String[] args  是什么意思呢?

     1 import java.util.Arrays;
     2 
     3 public class arr {
     4     public  static  void main(String[] args){
     5         int[] arr_test={1,2,3,4,5,6};
     6         int[] arr_res;
     7         arr_res= Arrays.copyOf(arr_test ,2*arr_test.length);
     8         for (int a:arr_res){
     9             System.out.println(a);
    10         }
    11     }
    12 }

     其中参数:String[] args 为命令行参数,读取命令行字符串数组。如果我们在命令执行的时候,会读取命令行带的参数,但是索引为0的位置,并不是脚本的本身,这点

    和python 区别开来!

    如下:

    1 public class command {
    2     public  static  void  main(String[] args){
    3         for (String a:args){
    4             System.out.printf("参数是: %s",a);
    5         };
    6     }
    7 }

     

  • 相关阅读:
    The Tamworth Two chapter 2.4
    USACO Controlling Companies chapter 2.3 已跪
    非递归快排
    链表二路归并
    Money Systems chapter 2.3 dp
    #pragma pack与sizeof union
    快慢指针
    12
    11
    10
  • 原文地址:https://www.cnblogs.com/evilliu/p/7598207.html
Copyright © 2011-2022 走看看