• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

please help me out

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi friends ,
i am confused with the statements.
in jls it is mentioned that decimal integer or factorial values give compile time error if the value is greater than the range
of data type but then
how come following program get compile without error
public class test {
public static void main(String args[])
{
int i = 1000000 ;
System.out.println(i*i);//here result is 1000000000000 which
which is out of integer range
}
}
rahul
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rahul,
The compiler doesn't compute i*i, it is performed at run-time.
If you want the compiler message then change your initialization to:
int i = 100000000000000;
Regards,
Manfred.
 
reply
    Bookmark Topic Watch Topic
  • New Topic