-1

I have this code: ArrayList<Integer> num_array = new Arraylist<Interger>();

WHY am I getting this error: "Syntax error, parameterized types are only available if source level is 1.5 or greater"

Robert Tossly
  • 613
  • 1
  • 6
  • 14
  • 1
    How do you compile this code? – Pshemo Oct 11 '15 at 21:58
  • Java generics were introduced with Java SE 5.0. You're using an older version. [This question also goes over solutions](http://stackoverflow.com/questions/15784591/java-generics-not-working) – Obicere Oct 11 '15 at 21:59
  • people still use 1.4? poor guys. – ZhongYu Oct 11 '15 at 22:00
  • How can I fix this? Also how can I view my current version of Java? – Robert Tossly Oct 11 '15 at 22:01
  • 1
    You still didn't tell us how you compile your code... – Pshemo Oct 11 '15 at 22:01
  • Sorry, in Eclipse Indigo – Robert Tossly Oct 11 '15 at 22:03
  • Possible duplicate of [What is "compiler compliance level" in Eclipse?](http://stackoverflow.com/questions/22584427/what-is-compiler-compliance-level-in-eclipse) – Tom Oct 11 '15 at 22:06
  • You should move to newer version of Eclipse. From what I remember Indigo can't support Java 8. Earliest version which supported it was Kepler (but you need to download additional plugin). Java 8 is being supported from Eclipse Luna. – Pshemo Oct 11 '15 at 22:08
  • Luna is still a little problematic with lambdas, especially autocomplete inside lamdas seem broken. Mars does a much better job – zapl Oct 11 '15 at 22:11

1 Answers1

1

In your eclipse, go to the menu under Window -> Preferences -> Java -> Compiler. That will allow you to change the java version with the "Compiler compliance level" setting, since it appears to be set to 1.4 or lower.

EDIT: Also, if that does not work, right click on the project in the Project Explorer to the left of the screen, choose Properties and select Java Compiler. Apply the same changes here as well.

AlphaModder
  • 3,266
  • 2
  • 28
  • 44
  • It was set to 1.4, I thank you sir. I am doing Java in school and we are expected to learn stuff on our own – Robert Tossly Oct 11 '15 at 22:09
  • @RobertTossly No problem! There's always a stage of figuring out where everything is in a new IDE. – AlphaModder Oct 11 '15 at 22:10
  • Hmmm... Not sure if you can answer this, but since I have changed my compiler to 1.7, I am still receiving the same errors. There was a notification about a total rebuild, do I need to create a new package perhaps? – Robert Tossly Oct 11 '15 at 22:12
  • @RobertTossly You can try either a) Going to `Project -> Clean...` and letting it clean all projects, and if that doesn't work, b) restart eclipse. – AlphaModder Oct 11 '15 at 22:14
  • Sadly, I have cleaned AND restarted Eclipse and still am getting this error :-/ Thanks for answering the initial question though!! :-) – Robert Tossly Oct 11 '15 at 22:17
  • @RobertTossly I might have another solution. I'll edit the answer, one moment. – AlphaModder Oct 11 '15 at 22:18
  • I owe my life to you sir. You want my car? You got it? Want a loan of my girlfriend? You got it! THANK YOU SO MUCH! My program is working fine now!! :'-) – Robert Tossly Oct 11 '15 at 22:26
  • @RobertTossly Haha, glad to help! – AlphaModder Oct 11 '15 at 22:27