Java Primitive Type Conversion Errors

Java Primitive Type Conversion Errors:

/*
 * This code won't compile
 */

public class TempError {
	public static void main(String[] args) {

		// can not implicitly cast double to integer
		int a = 3.4;

		// can not  implicitly cast integer to String
		string s = 3;

		// can not  implicitly cast integer to String
		string s1 = 4 + 5;

		// can not explicitly cast double to String
		string s2 = (String) 4.5;

		// can not explicitly cast integer to String
		string s3 = (String) 4;
	}
}
Advertisements