I am trying to learn java, and I’m in the wrapper classes topic. I am trying to use Boolean, Character, Integer and Double wrapper classes and assign value to them treating them as primitive data types. The tutorial I am watching is not having this error but I did.
Error: Exception in thread “main” java.lang.Error: Unresolved compilation problems:
Type mismatch: cannot convert from boolean to Boolean
Type mismatch: cannot convert from int to Integer
Type mismatch: cannot convert from double to Double
at MyPackage.Main.main(Main.java:19)
Here is the code:
Boolean a = true;
Character b;
Integer c = 123;
Double d = 3.14;
String e = "string";
How can I use this wrapper classes? Do I need to import something? If so, how?
Hun Mundin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1