Home » Java programming language

Java Character.Subset class toString() method with example

Character.Subset class toString() method: Here, we are going to learn about the toString() method of Character.Subset class with its syntax and example.
Submitted by Preeti Jain, on November 01, 2019

Character.Subset class toString() method

  • toString() method is available in java.lang package.
  • 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() 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() method is a final method it does not override in child class.
  • toString() method does not throw an exception at the time of conversion an object to a string.

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.

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





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.