subset java
Character.Subset类toString()方法 (Character.Subset class toString() method)
toString() method is available in java.lang package.
toString()方法在java.lang包中可用。
toString() method is used to return the string representation of this Subset object or in other words, we can say it returns the name of this Subset.
toString()方法用于返回此Subset对象的字符串表示形式,换句话说,可以说它返回此Subset的名称。
toString() method is a non-static method, it is accessible with the class name and if we try to access the method with the class object then we will not get any error.
toString()方法是一种非静态方法,可以使用类名进行访问,如果尝试使用类对象访问该方法,则不会出现任何错误。
toString() method is a final method it does not override in child class.
toString()方法是最终方法,不会在子类中重写。
toString() method does not throw an exception at the time of conversion an object to a string.
将对象转换为字符串时, toString()方法不会引发异常。
Syntax:
句法:
public final String toString();
Parameter(s):
参数:
It does not accept any parameter.
它不接受任何参数。
Return value:
返回值:
The return type of this method is String, it returns a string representation of this Subset object.
该方法的返回类型为String ,它返回此Subset对象的字符串表示形式。
Example:
例:
// Java program to demonstrate the example
// of String toString() method of
// Character.Subset class
public class ToStringOfCharacterSubset extends Character.Subset {
ToStringOfCharacterSubset(String str) {
super(str);
}
public static void main(String[] args) {
String str1 = new String("Java");
ToStringOfCharacterSubset ob1 = new ToStringOfCharacterSubset(str1);
String str2 = new String("Programming");
ToStringOfCharacterSubset ob2 = new ToStringOfCharacterSubset(str2);
String s1 = ob1.toString();
System.out.println("ob1:" + ob1);
System.out.println("ob1.toString(): " + s1);
System.out.println();
String s2 = ob2.toString();
System.out.println("ob2:" + ob2);
System.out.println("ob2.toString(): " + s2);
}
}
Output
输出量
ob1:Java
ob1.toString(): Java
ob2:Programming
ob2.toString(): Programming
翻译自: https://www.includehelp.com/java/character-subset-class-tostring-method-with-example.aspx
subset java