This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
You won't get a compiler error on line 1. char c1 is final and has one value once and for all. The char value of '2' can be converted into an int value of 50. This is a value that fits also into the byte range of a byte.
But you will get an error in line 2. The compiler sees that it gets a value that might have changed. You should also get an error in the "line in the middle" because you try to change a final variable. But the compiler sees the error in line 2 first and does not report the other one. If you change line 2 to return 1; (which is a legal return for a byte) then compiler would mark an error in the line in the middle: "final parameter c2 may not be assigned".
If you change the whole method to
Then the former line 2 is also wrong, because you cannot give a char back because it doesn't fit always into a byte. It does not help now that the char is final. Because you could easily invoke the method with a char value of - say '\u0080' (128, just one too big).
all events occur in real time
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com