Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #38669

Re: Overloading methods question

Path csiph.com!news.mixmin.net!news.albasani.net!.POSTED!not-for-mail
From Martin Gregorie <martin@mydomain.invalid>
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 <pr43lo$3rb$1@news.albasani.net> (permalink)
References <pqqmoq$jeo$1@dont-email.me> <1b2bqd7oqzez6$.sfpve8lwmic2.dlg@40tude.net> <pqt6v0$e65$1@dont-email.me> <75ad8b55-3def-4ec1-b46b-65ecd971d0fe@googlegroups.com> <pqtdpa$nl4$1@dont-email.me> <pqtg50$ga7$1@news.albasani.net> <pqtluk$gg9$1@gioia.aioe.org> <pqtnjm$abo$1@news.albasani.net> <pquv2d$6p2$1@dont-email.me> <pqvq6t$cah$1@news.albasani.net> <pr0d83$r6t$1@gioia.aioe.org> <pr2pa5$sql$1@news.albasani.net> <pr2sui$me8$1@gioia.aioe.org>
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

Show key headers only | View raw


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

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Overloading methods question Rhino <no_offline_contact@example.com> - 2018-10-24 17:04 -0400
  Re: Overloading methods question Arne Vajhøj <arne@vajhoej.dk> - 2018-10-24 18:56 -0400
  Re: Overloading methods question Joerg Meier <joergmmeier@arcor.de> - 2018-10-25 10:13 +0200
    Re: Overloading methods question Rhino <no_offline_contact@example.com> - 2018-10-25 15:53 -0400
      Re: Overloading methods question Eric Douglas <e.d.programmer@gmail.com> - 2018-10-25 13:58 -0700
        Re: Overloading methods question Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-10-25 17:49 -0400
          Re: Overloading methods question Martin Gregorie <martin@mydomain.invalid> - 2018-10-25 22:29 +0000
            Re: Overloading methods question Arne Vajhøj <arne@vajhoej.dk> - 2018-10-25 20:08 -0400
              Re: Overloading methods question Martin Gregorie <martin@mydomain.invalid> - 2018-10-26 00:37 +0000
                Re: Overloading methods question Arne Vajhøj <arne@vajhoej.dk> - 2018-10-25 21:42 -0400
                Re: Overloading methods question Joerg Meier <joergmmeier@arcor.de> - 2018-10-26 12:46 +0200
                Re: Overloading methods question Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-10-26 07:50 -0400
                Re: Overloading methods question Martin Gregorie <martin@mydomain.invalid> - 2018-10-26 19:33 +0000
                Re: Overloading methods question Eric Douglas <e.d.programmer@gmail.com> - 2018-10-26 13:13 -0700
                Re: Overloading methods question Arne Vajhøj <arne@vajhoej.dk> - 2018-10-26 20:58 -0400
                Re: Overloading methods question Martin Gregorie <martin@mydomain.invalid> - 2018-10-27 22:36 +0000
                Re: Overloading methods question Arne Vajhøj <arne@vajhoej.dk> - 2018-10-27 19:38 -0400
                Re: Overloading methods question Martin Gregorie <martin@mydomain.invalid> - 2018-10-28 10:39 +0000
                Re: Overloading methods question Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-10-28 07:54 -0400
          Re: Overloading methods question Eric Douglas <e.d.programmer@gmail.com> - 2018-10-26 06:26 -0700
      Re: Overloading methods question Joerg Meier <joergmmeier@arcor.de> - 2018-10-26 12:52 +0200
        Re: Overloading methods question Rhino <no_offline_contact@example.com> - 2018-10-26 22:10 -0400
          Re: Overloading methods question Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-10-27 07:43 -0400
            Re: Overloading methods question Rhino <no_offline_contact@example.com> - 2018-10-29 14:40 -0400
              Re: Overloading methods question Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-10-29 16:39 -0400
          Re: Overloading methods question Eric Douglas <e.d.programmer@gmail.com> - 2018-10-29 05:07 -0700
            Re: Overloading methods question Rhino <no_offline_contact@example.com> - 2018-10-29 14:41 -0400
  Re: Overloading methods question Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-10-25 07:49 -0400
    Re: Overloading methods question Rhino <no_offline_contact@example.com> - 2018-10-25 16:07 -0400

csiph-web