Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #39069
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Cecil Westerhof <Cecil@decebal.nl> |
| 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> (permalink) |
| References | <87o91amsyc.fsf@munus.decebal.nl> <qhv6p1$p7p$1@dont-email.me> |
| 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 |
Show key headers only | View raw
Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> 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
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
getFibonacciArray() cannot call getFibonacciArray(int from) Cecil Westerhof <Cecil@decebal.nl> - 2019-07-31 11:52 +0200
Re: getFibonacciArray() cannot call getFibonacciArray(int from) Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2019-08-01 19:15 +0200
Re: getFibonacciArray() cannot call getFibonacciArray(int from) Andreas Leitgeb <avl@logic.at> - 2019-08-02 06:51 +0000
Re: getFibonacciArray() cannot call getFibonacciArray(int from) Cecil Westerhof <Cecil@decebal.nl> - 2019-08-03 11:26 +0200
Re: getFibonacciArray() cannot call getFibonacciArray(int from) Cecil Westerhof <Cecil@decebal.nl> - 2019-08-03 11:11 +0200
csiph-web