How to add nodes to cluster through source code

In this post , he added nodes by ,
node.max_local_storage_nodes: 4 in elasticsearch.yml .

Is it not possible to hardcode the number of nodes in source code.