Why do we use the this
keyword along with the method name in Android to call a method from another method within the same class. In Java or C# we can call other method directly without the this
keyword, as in the code below.
public final String getElementValue( Node elem )
{
Node child;
if( elem != null)
{
if (elem.hasChildNodes())
{
for( child = elem.getFirstChild(); child != null; child = child.getNextSibling() )
{
if( child.getNodeType() == Node.TEXT_NODE )
{
return child.getNodeValue();
}
}
}
}
return "";
}
/**
* Getting node value
* @param Element node
* @param key string
* */
public String getValue(Element item, String str)
{
NodeList n = item.getElementsByTagName(str);
return this.getElementValue(n.item(0));
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…