Path: csiph.com!news.mixmin.net!news.albasani.net!.POSTED!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.programmer Subject: Re: Overloading methods question Date: Sun, 28 Oct 2018 10:39:52 +0000 (UTC) Organization: albasani.net Lines: 50 Message-ID: References: <1b2bqd7oqzez6$.sfpve8lwmic2.dlg@40tude.net> <75ad8b55-3def-4ec1-b46b-65ecd971d0fe@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: news.albasani.net UKO1Gdslmgap5NxVa5cYYAUvkRzSWf2MiDoxYBGhbHQWaW50acrVDlK87aOb73z+w/VmJo8jkIEaMCJQRIHnCw== NNTP-Posting-Date: Sun, 28 Oct 2018 10:39:52 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="WjO4EVe+FJWYgzDVpp6W+UIbaOf1b5gdX1AyodXwSj+vpGpJCftASQXEn9a7u5zKAvaRThFTephmr78kPlRjMSshhi6gxQpBhzWYzgbRYZ8KIBHXyHo3djV3QQBlMXax"; mail-complaints-to="abuse@albasani.net" User-Agent: Pan/0.145 (Duplicitous mercenary valetism; d7e168a git.gnome.org/pan2) Cancel-Lock: sha1:juzUgcQh9YX/bLf/GzV8/qiK7Bk= Xref: csiph.com comp.lang.java.programmer:38669 On Sat, 27 Oct 2018 19:38:56 -0400, Arne Vajhøj wrote: > public class TestRun { > public static void main(String args[]) > { > EnumWrapper ew = new EnumWrapper(); > ew.printVal(EnumWrapper.MyEnum.ONE); > } > } > > should work. > No, just a compilation failure: $ javac TestRun.java TestRun.java:7: error: cannot find symbol ew.printval(EnumWrapper.MyEnum.ONE); ^ symbol: method printval(MyEnum) location: variable ew of type EnumWrapper 1 error The answer in both cases turns out to be to put the sources in a directory called 'enum_test' and add "package enum_test;" to the sources. This allowed TestRun to compile and run while the less verbose and slightly modified TestRun2, with a second call to printVal(), now compiles and runs with an additional import statement: package enum_test; import enum_test.EnumWrapper.*; public class TestRun2 { public static void main(String args[]) { EnumWrapper ew = new EnumWrapper(); ew.printVal(MyEnum.ONE); ew.printVal(MyEnum.TREE); } } I can live with the additional import statement since it lets me put the enum where I want it. Thanks for your help. -- Martin | martin at Gregorie | gregorie dot org