Learn English – Using “in” and “with”

grammaticalityprepositionsword-choice

Although I know the clear meaning of commonly used prepositions in English, sometimes, I'm a little confused with them and cannot understand the difference between them. A week or so ago, I asked a question on StackOverflow which was titled by me as follows.

In this simple question title, Java is a programming language as everybody knows, "Varargs" (abbreviated to variable arguments, specifically variable number of arguments) and "method overloading" are two concepts used in the Java programming language. Before I asked the question, I was not sure at all whether the question title should have been as it is mentioned above or it should have been modified as follows.

  • Varargs with method overloading in Java.

Which one is grammatically correct, both or none of them?

Best Answer

With means 'accompanied' or 'by'.

In means 'enclosed' or 'surrounded by'.

Method overloading is calling what appears to be the same function in a program but - because different arguments can be given to the function - it is technically a different method being called. This concept of multiple methods that are the same is known as method overloading.

Varargs is shorthand for 'variable arguments' and is a way of passing a set of arguments to a method without explicitly identifying each individual argument.

Putting it all together:

1) Method overloading can be performed by (using) varargs. So 'method overloading with varargs' is fine.

2) Varargs and method overloading as programming concepts accompany each other. You use different arguments for the same named function in overloading. You provide different arguments to a method with varargs. So 'varargs with method overloading' also works.

3) Method overloading does not need to involve varargs. You can overload a method that takes only one argument instead of a set for instance. These other implementations suggest that conceptually method overloading is larger than, and encompasses, varargs. So 'varargs in method overloading' is correct.

You should not say method overloading in varargs. They can't enclose each other.

I would suggest that all three of the above are perfectly valid. Of them perhaps 2) would generally be less used, but in the context of your question, is absolutely correct.