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.
         * 
         */

How do I check what is in argv? I'm not familiar with this.

I'm assuming it checks if the database is already created or not. If its not created its -1. How would I check what is in argv and find when its -1?

argv is a String[] ?

teemo timmy
  • 37
  • 2
  • 4

3 Answers3

0

Yes, "argv" is just a String array.

For your code u can just do something like that:

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

String[] argv is a collection of Strings, separated by a space, which can be typed into the program on the terminal. You can find the more detail about it on this link:

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
        }
    }
}
Har Krishan
  • 273
  • 1
  • 11