-1

So for example lets say I used the console line

java AddPerson -c <sin> -g <gender> -age <age> -y <year> [-w <when>]

The inputs can be in any order and the -w input is optional.

My goal is to take these variables and add them to a database but I cant figure out how to find and store the inputted variables.

This is the 'pseudo-code' for what I have.

public AddPerson (String[] args) {

//connection to db

public boolean newPerson(){
}

       }
Daniel Ilie
  • 127
  • 7

1 Answers1

-1

you can pass arguments to java main method as below

AddPerson has to be a class containing main method

java AddPerson "valueOfSin" "Male" "30" "2021" "yesterday"
sanjeevRm
  • 1,541
  • 2
  • 13
  • 24
  • 1
    Im wondering how I would store those inputs, even if they were out of order (the -c, -g, -age specifies which entry it will be) – Daniel Ilie Mar 27 '21 at 23:32
  • you can use commons-cli to pass and parse named arguments http://commons.apache.org/proper/commons-cli/usage.html – sanjeevRm Mar 28 '21 at 00:06