Here's the simple rule. Implicit casts happen automatically when no data is lost (widening). Explicit casts require you to write the cast operator when data might be lost (narrowing).
// Implicit (automatic)
int a = 100;
long b = a;
double c = b;
// Explicit (you must cast)
double x = 9.7;
int y = (int) x;
byte z = (byte) y;
Watch out for overflow during explicit casts. If you cast 300 to a byte, the result wraps around because byte only holds to . (byte) 300 gives 44, not an error. Java trusts your cast and does not check if the value fits. Always verify that your value is in range before narrowing.