i understand why i'm getting the error on line no 2 cause the found return value is character and the return type is byte
but shouldn't i get the complile time error at line 1 also cause it is also returning the character value even though the return type is byte.... [ September 05, 2007: Message edited by: deeksha mehra ]
No, line 1 compiles fine. The variable is char but it is a final that is assigned a literal, so it is resolved at compile time. Java knows that the return value cannot be any other than \u0001, or 1. And so it knows that it fits a byte. Change that value to \u0101 and you will see it won't compile, because it knows the return value doesn't fit a byte.
That which doesn't kill us makes us stronger. I think a piece of pie wouldn't kill me. Tiny ad: