So, if you're an Aspiring Developer, Java Developer, VB 6.0 Developer or a developer with Visual Studio 2002/2003 then you have a good chance to ramp up to Visual Studio 2005. MSDN Ramp Up is a set of lessons for those who want to quickly learn and develop in VS 2005. http://msdn2.microsoft.com/en-us/rampup/default.aspx
I just hope they will have one for VS 2005 to VS 2008 soon.
Interesting programming ideas, solutions, and logic that I have used to solve problems or have come across throughout my career.
About Me
- William Andrus
- Northglenn, Colorado, United States
- I'm primarily a BI Developer on the Microsoft stack. I do sometimes touch upon other Microsoft stacks ( web development, application development, and sql server development).
Showing posts with label java. Show all posts
Showing posts with label java. Show all posts
Friday, October 26, 2007
Tuesday, October 03, 2006
Java Question:
Well, I was just browsing the Code Project's website and found this interesting. Given the following Java code:
Posted by: Dominik Reichl
Now, what are b1 and b2?
Surprisingly b1 is true, b2 is false.
Why?
Posted by: Dominik Reichl
Posted by: Dominik Reichl
Integer i = 1;
Integer j = 1;
Integer n = 1000;
Integer m = 1000;
boolean b1 = (i == j);
boolean b2 = (n == m);
Now, what are b1 and b2?
Surprisingly b1 is true, b2 is false.
Why?
Posted by: Dominik Reichl
Ok, so here's the solution why it works this way
First of all, we are using Integer wrapper classes instead of the primitive int type. When compiling, the integral values 1 and 1000 are implicitely converted to Integer objects (called auto-boxing, from int to Integer).
So, we got 4 different Integer instances, right? No!
The Java VM automatically packs "small" primitive values into identical objects (1 is small, 1000 isn't small). You can easily verify this by pasting the code above into a small testing project and fire up the debugger: i and j reference the same object, while n and m reference different objects. The == operator is comparing references, therefore b1 is true (same references) and b2 is false (different references).
Currently "small" means any integer between -128 and 127. But according to Sun this can change to [-32768, +32767] in the future. This packing trick has been introduced to solve performance problems when doing arithmetic with wrapper classes.
Subscribe to:
Posts (Atom)