subset java_Java Character.Subset类toString()方法的示例

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值