I cannot comment yet, so I will provide a preliminar answer with the information you gave so far, but I think it needs clarification.
As people already stated this question seems to relate to java optional parameters (especially: varargs of Object). Considering your example (main()) I also would go for a serie of overloaded methods but it considerably depends on the number of different optional arguments you expect to come with and any conflict of arguments ordering that may occur.
Other alternatives include defining an interface for your argument "SOMETHING_HERE" that could be filled in any possible mean at runtime (and also used anonymously). So among others (like using a map for variable typed args), you could eventually do as follow:
Eg.
public interface IDynLoadedArgs {
public Float getFloat(); // returns NULLABLE
public String getString(); // returns NULLABLE
}
public Class Test{
public void foo(int x, IDynLoadedArgs args){
...
}
}
public Class Main{
public static void main(String[]args){
Test test = new Test();
final String s1 = "Hello";
final float f1 = 5.5f;
test.foo(10, null); // = might equal test.foo(10);
test.foo(10, new IDynLoadedArgs() {
public Float getFloat(){
return null;
}
public String getString(){
return s1;
}
}); // = might equal test.foo(10, s1);
test.foo(10, new IDynLoadedArgs() {
public Float getFloat(){
return f1;
}
public String getString(){
return null;
}
}); // = might equal test.foo(10, f1);
test.foo(10, new IDynLoadedArgs() {
public Float getFloat(){
return f1;
}
public String getString(){
return s1;
}
}); // = might equal test.foo(10, f1, s1);
...
}
}
Of course you may instantiate IDynLoadedArgs objects in the classic way before calling "foo" (hence avoiding anonymous things side-effects and making these objects reusable..
Nevertheless as soon as you don't precise in your original question that order matters and what kind of treatment you expect of method "foo", it is hard to propose something definitely appropriate. Please clarify if possible.