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


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

Re: Type of an expression

Path csiph.com!news.mixmin.net!aioe.org!.POSTED!not-for-mail
From Arne Vajhøj <arne@vajhoej.dk>
Newsgroups comp.lang.java.programmer
Subject Re: Type of an expression
Date Wed, 25 Jan 2017 19:15:02 -0500
Organization Aioe.org NNTP Server
Lines 40
Message-ID <o6bf25$1shh$1@gioia.aioe.org> (permalink)
References <type-20170126001819@ram.dialup.fu-berlin.de>
NNTP-Posting-Host PBuS014lhzVyHjLbXmo/ZQ.user.gioia.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Complaints-To abuse@aioe.org
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0
X-Notice Filtered by postfilter v. 0.8.2
Xref csiph.com comp.lang.java.programmer:36219

Show key headers only | View raw


On 1/25/2017 6:37 PM, Stefan Ram wrote:
> public final class Main
> { public static void main( final java.lang.String[] args )
>   { main( args.length==0?"":0 ); }}
>
> Main.java:36: error: method main in class Main cannot be applied to given types;
>   { main( args.length==0?"":0 ); }}
>     ^
>   required: String[]
>   found: args.lengt[...]" : 0
>   reason: argument mismatch; bad type in conditional expression
>       String cannot be converted to String[]
> 1 error

> public final class Main
> { public static void main( final java.lang.String[] args )
>   { main( args.length==0?0:"" ); }}
>
> Main.java:36: error: method main in class Main cannot be applied to given types;
>   { main( args.length==0?0:"" ); }}
>     ^
>   required: String[]
>   found: INT#1
>   reason: argument mismatch; INT#1 cannot be converted to String[]
>   where INT#1,INT#2 are intersection types:
>     INT#1 extends Object,Serializable,Comparable<? extends INT#2>
>     INT#2 extends Object,Serializable,Comparable<?>
> 1 error

There are rules for this.

Language lawyers can find the rules in JLS 15.25.

Pragmatic programmers make sure to always have the two be the
same type to avoid confusion.

Arne


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


Thread

Re: Type of an expression Arne Vajhøj <arne@vajhoej.dk> - 2017-01-25 19:15 -0500

csiph-web