Sunday, October 4, 2009

Operators VB vs Java

What's the output from these two functions in VB and Java respectively:

Public Sub PrintThings()
Console.WriteLine("3" + "6")
Console.WriteLine(3 & 6)
End Sub


public void printThings() {
System.out.println("3" + "6");
System.out.println(3 & 6);
}

3 comments:

Andy said...

VB: 36, 36
Java: 36, 2

Okay, what was the trick?

thejoshwolfe said...

VB: 9, 36
Java: 36, 2

Andy said...

ahh, you got me. I never used + for concatenation in VB, 'cause I was a good citizen.