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


Groups > comp.lang.java.programmer > #39150 > unrolled thread

Re: Surprise!

Started byKnute Johnson <nospam@rabbitbrush.frazmtn.com>
First post2019-09-19 17:46 -0500
Last post2019-09-19 17:46 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.java.programmer

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Surprise! Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2019-09-19 17:46 -0500

#39150 — Re: Surprise!

FromKnute Johnson <nospam@rabbitbrush.frazmtn.com>
Date2019-09-19 17:46 -0500
SubjectRe: Surprise!
Message-ID<qm10gv$tpf$1@dont-email.me>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web