Did Java 8 is not allow overload anymore ?

Did Java 8 can’t overload anymore ?
ps. I just back to Java and Try to move my code from Java 6 > Java 8

And… I just got bug

[quote]The method is ambiguous for the type .
[/quote]
and I not sure how to fix it can anyone tell me about this please :slight_smile: thanks you.

That is generics, not overloading, overloading was never in java.

simply, overloading changes what +, -, += etc do.

Generics still exist, your probably doing something that does not use generics.

What is it your trying to use it for?

EDIT: I think I may of read it wrong, with seeing the < > and assuming it was generics.

I am assuming you mean method overloading.

You probably just copied pasted the exact method description, and expected it work.


public void test(int x) { System.out.println(x); }
public void test(int x) { System.out.println(x + 1); }

I am guessing you did something like that, where it does not know what method to call, I have never got that message.

That or your making a generic method as well


public void test(int x) { System.out.println(x); }
public void test(T x) { System.out.println(x); } //where T is your type

and you set your type as a int, so its just 2 methods, that take the exact same parameters.

I have


import static kimoi.engine.settings.Preference.newPreference;
import static kimoi.engine.styledtext.TextStylePreference.newPreference;

and It’s said (In Java8)

[quote]The method newPreference(String, boolean, String, String) is ambiguous for the type VNPrefs
[/quote]
but Java6 and Eclipse juno is fine, no error.

EDIT forgot to copy this :stuck_out_tongue:


public static final Preference<Boolean> SCRIPT_DEBUG = newPreference("vn.scriptDebug", false, "Script Debug", "Certain functions detect and warn about additional errors when script debug is turned on.");
	
public static final Preference<Integer> FPS = newPreference("vn.fps", 60, "Framerate", "The target game update and redraw rate in frames per second.");
	
public static final Preference<TextStyle> TEXT_STYLE = newPreference("vn.textStyle", new TextStyle(null, FontStyle.PLAIN, 30), "Default Text Style", "The default style to be used for rendered text.");

if I comment ( // )

//import static kimoi.engine.settings.Preference.newPreference;

Some static is fine but other is not in this line

public static final Preference<TextStyle>

You have imported two static methods with the same signature. To disambiguate them you will need to fully-qualify which one you wanted.
Tip: Don’t statically import two identical methods.

Cas :slight_smile:

Thanks you princec
Working on it now :slight_smile: hope it works :smiley:

EDIT

oh btw… Did anyone Using RoboVM ? I’m just interesting about this :slight_smile:

Okay nvm.