0

i am trying to make an ArrayList of type integer, but it gives me this error(I am using this compiler called jikes) Code:

   ArrayList<Integer> = new ArrayList<Integer>();

Error:

***Semantic error: using type arguments to access generic types requires the use of "-source 1.5"'or greater. Compilation will continue to use the raw type "Java.util.arraylist", but no class file will be emitted.

4
  • 10
    Every variable needs a name, so give "him" one: ArrayList<Integer> list = new ArrayList<Integer>();. And your compiler level is most likely 1.4. You need at least 1.5 to use generics. Read the manual/help page of your compiler to find out how to do that. Commented Feb 24, 2015 at 19:41
  • Which Java Version do you use? Commented Feb 24, 2015 at 19:45
  • Looking a jikes: any good reason you are using just that? Commented Feb 24, 2015 at 19:47
  • @Tom: Make that an answer. Because it is. Commented Feb 24, 2015 at 20:29

3 Answers 3

2

Your arraylist has no name:

ArrayList<Integer> name = new ArrayList<>();
Sign up to request clarification or add additional context in comments.

1 Comment

The reference has no name :).
1

try following:

List<Integer> list = new ArrayList<Integer>();

4 Comments

Please can you explain why - code only answers usually require an explanation.
Because you never named the variable.
I just noticed that... Whoops. Ignore me.
@Araymer No problem. You can delete your own comments if you like.
0

Correct initialization should be

ArrayList<Integer> X = new ArrayList<Integer>();

you need to assign variable

1 Comment

True, but if i knew what application does i would have given better name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.