Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #39069
| From | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: getFibonacciArray() cannot call getFibonacciArray(int from) |
| Date | 2019-08-03 11:26 +0200 |
| Organization | Decebal Computing |
| Message-ID | <87a7cqmwg5.fsf@munus.decebal.nl> (permalink) |
| References | <87o91amsyc.fsf@munus.decebal.nl> <qhv6p1$p7p$1@dont-email.me> |
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