0

I have objects that look like this:

{id:1,name:john,age:15},{id:2,name:david,age:40}....

And I want to pass them to my java program as arguments and keep the connection between them.
If I could do something like that:

public static void main(Object[] args){
}


It could solve my problem but I can't so I thought about this solution:
Argument one:"1,2"
Argument two:"john,david"
Argument three:"15,40"
Then, split each Arg by ',' And keep the relationship between them by the place in the array
I don't like this solution.
Do you know better solution for this problem?

1 Answer 1

3

The static void main method is the starting point of every java application.

public static void main(String[] args){

if you modify that signature, the application never find a start point to be executed...

the most you can do is pass a string

the signature can not be modified to this

public static void main(Object[] args){
}

it must be always

public static void main(String[] args){
}

so you still have one shot, put this:

{id:1,name:john,age:15},{id:2,name:david,age:40}

in a text File and pass the Path as string to the app so it can be found

Sign up to request clarification or add additional context in comments.

4 Comments

Or, pass the String to main and parse it. If it is large, the file is a better idea.
What do you define as "large"? 300 objects its large or it's better to pass as string?
It will be only 3 parametrs. But each parameter will be very long(will hold 300 values)
Put the values in a file, and then pass the file name as a parameter for it to read the values from. You could also use a JSON parser and put them in JSON format if that is easier for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.