Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #39150
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Knute Johnson <nospam@rabbitbrush.frazmtn.com> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Surprise! |
| Date | Thu, 19 Sep 2019 17:46:53 -0500 |
| Organization | A noiseless patient Spider |
| Lines | 32 |
| Message-ID | <qm10gv$tpf$1@dont-email.me> (permalink) |
| References | <Main.java-20190919202538@ram.dialup.fu-berlin.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Thu, 19 Sep 2019 22:46:56 -0000 (UTC) |
| Injection-Info | reader02.eternal-september.org; posting-host="a8952e4781329cacf3a25d3f82899adf"; logging-data="30511"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/nnfYUb29hEc5DM2Dxq4Bu" |
| User-Agent | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 |
| Cancel-Lock | sha1:cWIUWZIkTiYwoCmR60nuy4+SIv8= |
| In-Reply-To | <Main.java-20190919202538@ram.dialup.fu-berlin.de> |
| Content-Language | en-US |
| Xref | csiph.com comp.lang.java.programmer:39150 |
Show key headers only | View raw
On 9/19/2019 14:28, Stefan Ram wrote:
> Write this:
>
> public final class A
> { public static void main( final java.lang.String[] args )
> { B.hello(); }}
>
> public final class B
> { public static void hello()
> { java.lang.System.out.println( "Hello!" ); }}
>
> and save it as "Main.java". Then call:
>
> java Main.java
>
> with a recent JDK. What you have there is a file named
> "Main.java" that does /not/ contain a class "Main", and
> it has /two/ public classes. Yet, the above command will
> happily print,
>
> Hello!
>
> .
>
>
Apparently it calls the main() in the first class. I tried putting a
main() in B but it didn't compile.
--
Knute Johnson
Back to comp.lang.java.programmer | Previous | Next | Find similar | Unroll thread
Re: Surprise! Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2019-09-19 17:46 -0500
csiph-web