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


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

Re: Surprise!

Path csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From Martin Gregorie <martin@mydomain.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Surprise!
Date Thu, 19 Sep 2019 20:47:19 -0000 (UTC)
Organization A noiseless patient Spider
Lines 33
Message-ID <qm0pgn$h50$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
Content-Transfer-Encoding 8bit
Injection-Date Thu, 19 Sep 2019 20:47:19 -0000 (UTC)
Injection-Info reader02.eternal-september.org; posting-host="c25735750e8f7007b893153b1d2a7646"; logging-data="17568"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+JggW18cXjqNQCLExj9+yvYhR3M75uQEc="
User-Agent Pan/0.145 (Duplicitous mercenary valetism; d7e168a git.gnome.org/pan2)
Cancel-Lock sha1:mh+1mnTgaikeYrsXSKOiO/Ia/uQ=
Xref csiph.com comp.lang.java.programmer:39148

Show key headers only | View raw


On Thu, 19 Sep 2019 19:28:50 +0000, 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!
> 
>
Not with the latest Open JDK 1.8 it doesn't: this just complains the A 
should be on A.java and B should be in B.java

Maybe later Java versions removed the "ClassName == ClassName.java" and 
"public static void main(String[])" requirements to make scripting easier?


-- 
Martin    | martin at
Gregorie  | gregorie dot org

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


Thread

Re: Surprise! Martin Gregorie <martin@mydomain.invalid> - 2019-09-19 20:47 +0000
  Re: Surprise! Eric Douglas <e.d.programmer@gmail.com> - 2019-09-19 14:01 -0700
    Re: Surprise! Martin Gregorie <martin@mydomain.invalid> - 2019-09-19 23:18 +0000
      Re: Surprise! Knute Johnson <groups@585ranch.com> - 2019-09-19 20:03 -0500
      Re: Surprise! Eric Douglas <e.d.programmer@gmail.com> - 2019-09-20 08:03 -0700
        Re: Surprise! Arne Vajhøj <arne@vajhoej.dk> - 2019-09-20 19:01 -0400

csiph-web