Converting Objects to Strings with toString() Method in Java: A Comprehensive Guide

Rumman Ansari   Software Engineer   2024-07-04 04:45:29   6180  Share
Subject Syllabus DetailsSubject Details 1 Program
☰ TContent
☰Fullscreen

Table of Content:

Description

This method returns a String object representing the specified character value, that is, a one-character string.

Method Syntax

String toString(char ch)

Method Argument

Here is the detail of parameters ?

  • ch ? Primitive character type.

Method Returns

toString() Method method returns String object.

Compatibility

Requires Java 1.5 and up

Example

Below is a simple java example on the usage of toLowerCase(char ch) method of Character class.

public class MethodtoString {

   public static void main(String args[]) {
      System.out.println(Character.toString('s'));
      System.out.println(Character.toString('S'));
   }
}

output

Below is the sample output when you run the above example.

s
S
Press any key to continue . . .