This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
The following isn't an example of casting (explicit or implicit):
The variable out is of type PrintStream in class System. Class PrintStream defines overloaded println methods to accept and write different types of data. In the above mentioned line of code, you are not using implicit or explicit casting. You are calling overloaded println method.
The following code uses a method to convert an int value to String:
Mala when i cast it to (byte) it will work fine. So according to your explanation the PrinStream class does'nt have any overlaoded method which take byte . So we have to cast it to byte or String.
Am i understading it correctly. Please correct me if i am wrong.
From my perspective,
System.out.println(b); // does implicit casting by compiler (converting byte to int is always safe).
String byteToString = Byte.toString((byte)20); // need explicit casting by converting int to byte(not safe, because int might exceed the range of byte. It's your responsibility to make sure it's safe).
subject: Doubt regarding explicit cast and implicit cast