In this post, we will see about error insert dimensions to complete referencetype.
You will get this error when you are trying to pass primitive objects into generic type declaration but generic always expect a Wrapper class in java.
For example:
Let’s say you have the below class named InsertDimensionlMain.java.
|
1 2 3 4 5 6 7 8 9 10 |
package org.arpit.java2blog; public class InsertDimensionlMain { public static void main(String[] args) { Map<int,String> map; } } |
Above code won’t compile, you will a compilation error with "insert dimensions to complete referencetype".
![]()
You can solve this issue by replacing int by its wrapper class Integer in Map declaration.
|
1 2 3 4 5 6 7 8 9 10 |
package org.arpit.java2blog; public class InsertDimensionlMain { public static void main(String[] args) { Map<Integer,String> map; } } |
Let’s see another example with ArrayList.
|
1 2 3 4 5 6 7 8 9 10 |
package org.arpit.java2blog; public class InsertDimensionlMain { public static void main(String[] args) { ArrayList<double> listOfPrices; } } |
Here also we will get same issue.
![]()
You can solve this issue by replacing double by its wrapper class Double.
|
1 2 3 4 5 6 7 8 9 10 |
package org.arpit.java2blog; public class InsertDimensionlMain { public static void main(String[] args) { ArrayList<Double> listOfPrices; } } |
That’s all about how to resolve insert dimensions to complete referencetype in java.