Search code examples
javahistorylanguage-design

Why Java can take multiple parameters but can return only a single object?


Why was java defined such that methods may take as input multiple parameters,
but may only return a single object (or void)?

Did it make the language somehow easier to implement or use?


Solution

  • Probably because this is the way that C and C++ do it, and the Java language syntax is very similar to (and probably based on) those languages.

    In fact, according to this article, Gosling started by extending the C++ compiler, so it makes sense that he would follow much of the same syntax:

    To make development a more platform-neutral process (and thus accommodate the consumer market's demand for CPU flexibility), Gosling began by extending the C++ compiler.