I have the scenario where we used to implement the interface members using explicit implementation in C#. Currently I need to achieve the same behavior in JAVA, but couldn’t explicitly call the interface members, hence it shows error to mark the implemented member as public. I am new to JAVA, kindly let me know how the achieve the same behavior in JAVA.
C# Code:
public class WF_33470: IData
{
private string m_data = string.Empty;
string IData.Element
{
get
{
return m_data;
}
}
string IData.Data()
{
get
{
return "Hello World";
}
{
}
internal interface IData
{
string Element
{
get;
}
string Data();
}
Java Code:
public class WF_33470 implements IData
{
private String m_data = "";
String getElement()throws Exception{//throws error to change the modifier to be public, but i need to achieve explicit implementation here
return m_data;
}
String Data()throws Exception{//throws error to change the modifier to be public, but i need to achieve explicit implementation here
return "Hello World";
}
}
interface IData
{
String getElement()throws Exception;
String Data()throws Exception;
}