Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Generics error  RSS feed

 
Laurie carrera
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following code:



gives me the following error, at line 7 in the code, i.e the start of the if statement:
generics are not supported in -source 1.4 (try -source 1.5 to enable generics) java error.
What does it mean? Also I use source 1.5, I don't know why the system reads it as 1.4.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That "if" line has a number of syntax errors; there's nothing generics-related about it, but the compiler is so confused I suppose it's thinking that's what you're trying to express. Here's the offending line:

if (relation ="family" && (age>= 18){

Problem one: "=" is an assignment operator, not a comparison operator, so you meant "==" instead. Still, you can't use "==" to compare Strings (unless you really know what you're doing; use the equals() method instead.

Problem two: there's a missing close-parenthesis before the open-brace.

So altogether, I might write this as

if (relation.equals("family") && age >= 18) {
 
Laurie carrera
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured out the error a few secs after I posted this topic. It was an oversight on my part. Sorry about that, I shouldn't be making such mistakes at this point.

Thanks anyway.
 
sangineni phaninder
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
" please help me how to post"
 
Burkhard Hassel
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sangineni phaninder
Member # 136951

posted October 28, 2006 03:58 AM
" please help me how to post"


Hi, cowboy,
welcome to the Java Ranch!

Perhaps try this first:
http://faq.javaranch.com/view?JavaRanchFaq


And: Did you notice, your member number is a prime?


Yours,
Bu.
 
Burkhard Hassel
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Laurie,

and your member number is prime as well...
Bu.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!