I am initiating object array as below:
Object a[] = new Object[4];
a[0] = 1; //while assigning integer value, am getting an error: "Type mismatch: Cannot convert Integer to Object
a[1] = 'A'; //while assigning char value, am getting an error: "Type mismatch: Cannot convert char to Object
a[2] = 12.33//while assigning integer value, am getting an error: "Type mismatch: Cannot convert double to Object
a[3] = "Hello"; //Accepting only string values.
PLease suggest where went wrong? is it configuration issue? I am using:
Java Version jdk1.8.0_151,
jre1.8.0_151,
Eclipse Java EE IDE for Web Developers.
Version: Oxygen.2 Release (4.7.2)
Build id: 20171218-0600
This is exactly the error message you would be getting if you are using a compiler compliance level lower than 5. Note that this is different from the Java version on your system. See the fix here https://stackoverflow.com/a/24591529/11595728 .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With