Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,156,780 members, 7,831,513 topics. Date: Friday, 17 May 2024 at 08:01 PM

Explain This Code Please: - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Explain This Code Please: (836 Views)

5,000 Naira For Someone Who Can Reverse This Code / Need Help With This Code / Please Help With These Code Please (2) (3) (4)

(1) (Reply)

Explain This Code Please: by saragondla: 5:42am On Nov 24, 2009
public class B {

public int add()
{
return 011;
}
public static void main(String[] args)
{
B b1=new B();
//System.out.println(!new Boolean(false));
System.out.println(b1.add());
}

here output will give :9 . how it will come like this please explain me any one,

}
Re: Explain This Code Please: by logica(m): 7:46am On Nov 24, 2009
The int value 011 represents an octal value. In Java, any integral value that starts with 0 is assumed to be in the octal system (base-cool. Please go read about literal values in Java.  011 converted to the standard decimal (base-10) is 9, which is the default numerical system except otherwise specified, therefore 9 is printed.

(1) (Reply)

Feel Like / 2013 Global Apps To Empower Contest / Critical Success Factors To Know When Building Mobile Website And App

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 4
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.