top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Which declaration gives error in JAVA and why?

+1 vote
555 views
1)double d=0786; 

2)double d=0x4b17;
posted Feb 13, 2016 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes

double d=0786; will give the compilation error in Java (integer number too large: 0786). Numbers beginning with 0 are considered octal and allowed digits are 0-7 and 8 is not allowed.

Any number starting with 0x is hex number and allowed digits are 0-9,a-f hence there is no issue with second statement.

answer Feb 13, 2016 by Salil Agrawal
Similar Questions
+1 vote

Why the following program gives an error?

#include <stdio.h>

int main() 
{
    unsigned int64_t i = 12;
    printf("%lld\n", i);
    return 0;
}

Error:

 In function 'main':
5:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'i'
  unsigned int64_t i = 12;
               ^
5:19: error: 'i' undeclared (first use in this function)
5:19: note: each undeclared identifier is reported only once for each function it appears in

But, If I remove the unsigned keyword, it's working fine. So, Why unsigned int64_t i gives an error?

+1 vote

Example: consider this string
" Parse this date string 10 juil 2014 @@@parse date " OR "10 juil 2014" (This is easy with SimpleDateFormat using Locale.French) but I want the solution to extract date first from the string and then convert to Date using SimpleDateFormat.

...