Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Cecil Westerhof Newsgroups: comp.lang.java.programmer Subject: Re: getFibonacciArray() cannot call getFibonacciArray(int from) Date: Sat, 03 Aug 2019 11:26:18 +0200 Organization: Decebal Computing Lines: 52 Message-ID: <87a7cqmwg5.fsf@munus.decebal.nl> References: <87o91amsyc.fsf@munus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="9028278f6a1573c2cfa07bfbf5ff71f7"; logging-data="20023"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19UXorgLVv83FCQS558KFKKvfc1XuN4N+g=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) Cancel-Lock: sha1:wzBZZiLl5dJAW7+m3XRJjWIVMzQ= sha1:acknySdFs1rcmdiYUeJ0ahVbCKE= Xref: csiph.com comp.lang.java.programmer:39069 Daniele Futtorovic writes: > On 2019-07-31 11:52, Cecil Westerhof wrote: > If I had to hazard a guess, I would say that in jshell, you can't > reference a method before you've declared it (lexically speaking). No, that is not the problem. A method cannot call an overridden version of itself in jshell, while it can in a class. :'-( I have the following in test.jsh: void greeter() { printGreeting("Hello world."); } void printGreeting(String msg) { println(msg); } int getInt(int value) { return value; } int getInt() { return getInt(12); } When I open this with '/open', I get: | Error: | method getInt in class cannot be applied to given types; | required: no arguments | found: int | reason: actual and formal argument lists differ in length | return getInt(12); | ^----^ So greeter does not have any problem with printGreeting not being defined. Another strange thing: getInt() is defined. But when I call it, I get (as expected): | Error: | method getInt in class cannot be applied to given types; | required: no arguments | found: int | reason: actual and formal argument lists differ in length | return getInt(12); | ^----^ -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof