Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #39150
| From | Knute Johnson <nospam@rabbitbrush.frazmtn.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Surprise! |
| Date | 2019-09-19 17:46 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <qm10gv$tpf$1@dont-email.me> (permalink) |
| References | <Main.java-20190919202538@ram.dialup.fu-berlin.de> |
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