2017-11-22 1 views
0
public static void main(String[] argv) { 

     Connection connection = DatabaseDriverExtender.connectOrCreateDataBase(); 
     if (connection == null) { 
     System.out.print("NOOO"); 
     } 
     try { 
     //TODO Check what is in argv 
     //If it is -1 
     /* 
     * TODO This is for the first run only! 
     * Add this code: 
     * DatabaseDriverExtender.initialize(connection); 
     * Then add code to create your first account, an administrator with a password 
     * Once this is done, create an employee account as well. 
     * 
     */ 

argv에 무엇이 있는지 어떻게 확인합니까? 나는 이것에 익숙하지 않다.argv에 무엇이 있습니까?

데이터베이스가 이미 생성되었는지 여부를 확인한다고 가정합니다. 그것의 -1 생성하지 않은 경우. argv에있는 내용을 확인하고 -1을 발견하면 어떻게됩니까?

argv가 문자열 []입니까?

+0

가 왜? – Dabiuteef

+0

주 함수에서 argv는 명령 줄에서 전달 된 인수 배열입니다. –

+0

@Dabiuteef 그런 식으로하려고합니다. -1이 먼저 실행됩니다. 나는 단지 어떻게 해야할지 모르겠다. –

답변

0

예, "argv"는 문자열 배열입니다.

은 당신의 코드에 대해 u는 그냥 같은 것을 할 수 있습니다

if (argv.length > 0) { 
//check if argv[0].equals("-1") or something like that 
} 
0

문자열 [] argv를 터미널에서 프로그램에 입력 할 수있는 공간으로 구분 된 문자열의 집합입니다. 당신은이 링크에 대한 자세한 내용을 확인할 수 있습니다. "나는 데이터베이스가 이미 작성 또는되어 있지 않은 경우는 확인 있으리라 믿고있어"

What is "String args[]"? parameter in main method Java

0
//when using main method argv cannot be null. But if using somehwere else check if array is not null and then access the elements 
public static void main(String[] argv) { 
    int len=argv.length; 
    System.out.println("No. of elements :"+len); 
    for(int i=0; i<len; i++){ 
     String indexValue=argv[i]; 
     System.out.println("Array Index value:"+indexValue); 
     if("-1".equals(indexValue)){ 
      //value is -1 
     }else{ 
      //value is not -1 
     } 
    } 
} 
관련 문제