string - Java Method Confusion -
In Java, for example, when you call string1.compareTo (string2), how to compare the comparison method to string 1 is? I see the method in the second string, but how does it compare it for the first time, if it is not being passed?
compareTo () is the member function of class string, this means that to implement this function You need an object of type string. So when you call string1.compareTo (string2), it means that you are bringing the string object to ' string1 ' on the Compare () function and ' String2 'as argument.
Comments
Post a Comment