MosheCh
MosheCh

Reputation: 99

Passing Object Parameter To Main Function Java

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?

Upvotes: 0

Views: 2096

Answers (1)

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

Upvotes: 3

Related Questions