Reputation:
I'm writing code in Java, using the NetBeans IDE. I keep getting a couple of "Incompatible Type" errors. I declare a variable as String and then assign to it the value from a method that returns a String too. The error says that there was expected a type of "String" but instead found "..." where "..." the name of the method I call.
For example, this is a line that gives me the error:
incompatible types found: encode_monoalphabetic_engine required: java.lang.String encoded = encode_monoalphabetic_engine(string);
Upvotes: 0
Views: 2339
Reputation: 3577
I agree with kd304, it looks like the program isn't recognizing the method call as such. I'm assuming that "string" is your variable name for a String object. Just make sure you're calling the method correctly and that the method returns a String data type.
Upvotes: 0
Reputation: 69997
I think the compiler doesn't recognize encode_monoalphabetic_engine as a method/function. Maybe you have some naming conflicts or bad scope.
Upvotes: 0
Reputation: 18702
Make sure that the other method is returning also a "java.lang.String", not a user defined object "string".
Upvotes: 1
Reputation: 50227
Perhaps you could post a more complete code snippet?
It looks like your method argument string
isn't a java.lang.String
?
Upvotes: 0