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;
	}
}

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s