Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • radha gogia

    @radha-BTDzli Sep 4, 2014

    anksinglabyte b=10 shows no error but
    float f =10.0 shows error that double found..

    why??

    see in java by default each decimal value is taken as double so u need to explicitly mention it be ,say 5.98f becoz it wont take it otherwise float,it would take it to be double,similarly byte b=18;here 18 is int by default but its value lies in the range of byte numbers that is we can represent 18 in byte so i hope now u are clear

  • anksingla

    @anksingla-ttYJbX Sep 4, 2014

    radha gogiasee in java by default each decimal value is taken as double so u need to explicitly mention it be ,say 5.98f becoz it wont take it otherwise float,it would take it to be double,similarly byte b=18;here 18 is int by default but its value lies in the range of byte numbers that is we can represent 18 in byte so i hope now u are clear

    But if 10 is int then it should not be matters that value comes in range of byte or not. Since java does not type demotion.