LiamTheBox@lemmy.world to Greentext@sh.itjust.works · 2 months agoAnon tries programming in Javalemmy.worldexternal-linkmessage-square228fedilinkarrow-up11arrow-down10
arrow-up11arrow-down1external-linkAnon tries programming in Javalemmy.worldLiamTheBox@lemmy.world to Greentext@sh.itjust.works · 2 months agomessage-square228fedilink
minus-squareWillem@kutsuya.devlinkfedilinkarrow-up0·2 months agoOn that last note, can’t you use the explicit interface implementation in C#? e.g. public class SampleClass : IControl, ISurface { void IControl.Paint() { System.Console.WriteLine("IControl.Paint"); } void ISurface.Paint() { System.Console.WriteLine("ISurface.Paint"); } }
minus-squarepivot_root@lemmy.worldlinkfedilinkarrow-up0·edit-22 months agoI haven’t kept up with recent Java developments, but with Go, you’re out of luck. Interface implementations are—for both better and worse—completely implicit. Edit: For Java, it still appears to be that you’re stuck designing around the language: https://stackoverflow.com/questions/19111090/does-java-support-explicit-interface-implementation-like-c
minus-squareඞmir@lemmy.mllinkfedilinkarrow-up0·2 months agoHe mentioned C#, which does let you explicitly choose to implement same-name functions of two interfaces with different code
minus-squarepivot_root@lemmy.worldlinkfedilinkarrow-up0·edit-22 months agoFor some reason, my brain inserted a “like” before “in C#”, and answered the question of “can’t you use explicit interfaces like in C#.”
On that last note, can’t you use the explicit interface implementation in C#?
e.g.
public class SampleClass : IControl, ISurface { void IControl.Paint() { System.Console.WriteLine("IControl.Paint"); } void ISurface.Paint() { System.Console.WriteLine("ISurface.Paint"); } }
I haven’t kept up with recent Java developments, but with Go, you’re out of luck. Interface implementations are—for both better and worse—completely implicit.
Edit: For Java, it still appears to be that you’re stuck designing around the language: https://stackoverflow.com/questions/19111090/does-java-support-explicit-interface-implementation-like-c
He mentioned C#, which does let you explicitly choose to implement same-name functions of two interfaces with different code
For some reason, my brain inserted a “like” before “in C#”, and answered the question of “can’t you use explicit interfaces like in C#.”