Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!ipa.eternal-september.org!.POSTED!not-for-mail From: Jukka Lahtinen Newsgroups: comp.lang.java.programmer Subject: Re: Every expression has a type? Date: Tue, 31 Oct 2017 12:00:28 +0200 Organization: A noiseless patient Spider Lines: 24 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit Injection-Info: ipa.eternal-september.org; posting-host="29008d6ba4f4f0600a8794d9a8721812"; logging-data="32459"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19kBtW0qjoOtJ1W3OhmbgAG" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) Cancel-Lock: sha1:tSFJG1uV2QU2lSY1G2v+4Z4az9s= sha1:YulbGi8ShwjJXc1vIidkE0WDo0U= X-no-archive: yes Xref: csiph.com comp.lang.java.programmer:37617 ram@zedat.fu-berlin.de (Stefan Ram) writes: > Jukka Lahtinen writes: >>How about null? >>Is it cosidered to have a type, since null can be any type at all? > I have written this exercise. > Try to predict the output of the following program. > public final class Main > { > private static void f( final java.lang.Object o ) > { java.lang.System.out.println( "Bject" ); } > > private static void f( final java.lang.String s ) > { java.lang.System.out.println( "Tring" ); } > > public static void main( final java.lang.String[] args ) > { f( null ); }} Actually I'm surprised of the output of that. Just the opposite of what I thought. -- Jukka Lahtinen