Reputation: 1791
I just start to learn Java and I am getting "@SuppressWarnings("unchecked")"
I am sure that one of my static variable is making trouble
static ArrayList<Integer>[] docNumber = (ArrayList<Integer>[]) new ArrayList[20];
eclipse said "Type safety: Unchecked cast from ArrayList[] to ArrayList[]" but i am not really sure how to avoid this problem
can you tell me how to fix this problem?
thanks
Upvotes: 1
Views: 258
Reputation: 13272
In order to avoid the @SuppressWarnings(“unchecked”)
you should give the compiler the information needed to perform all type checks that would be necessary to ensure type safety, see unchecked FAQ.
In your case, I assume that you are trying to maintain a list of document integers, for this you will need:
List<Integer> docNumber=new ArrayList<Integer>();
If you would like to keep a list of lists then you can do:
List<List<Integer>> docNumber=new ArrayList<List<Integer>>();
Upvotes: 1
Reputation: 34367
Are you trying to achieve this (List of Array Of Integer
)?
static ArrayList<Integer[]> docNumber = new ArrayList<Integer[]>();
Upvotes: 0