Open In App

Bidi toString() method in Java with Examples

Improve
Improve
Like Article
Like
Save
Share
Report

The toString() method of java.text.Bidi class is used to display this Bidi instance in string representation.

Syntax:

public String toString()

Parameter: This method accepts nothing as parameter.

Return Value: This method display internal state of bidi in string format.

Below are the examples to illustrate the toString() method:

Example 1:




// Java program to demonstrate
// toString() method
  
import java.text.*;
import java.util.*;
import java.io.*;
  
public class GFG {
    public static void main(String[] argv)
    {
        // creating and initializing Bidi
        Bidi bidi
            = new Bidi("Geeks",
                       Bidi.DIRECTION_LEFT_TO_RIGHT);
  
        // getting the internal state of bidi
        // using toString() method
        String status = bidi.toString();
  
        // display the result
        System.out.println("status of bidi : "
                           + status);
    }
}


Output:

status of bidi :
 sun.text.bidi.BidiBase[
  dir: 0 
  baselevel: 0
  length: 5
  runs: [0 0 0 0 0]
  text: [0x47 0x65 0x65 0x6b 0x73]]

Example 2:




// Java program to demonstrate
// toString() method
  
import java.text.*;
import java.util.*;
import java.io.*;
  
public class GFG {
    public static void main(String[] argv)
    {
        // creating and initializing Bidi
        Bidi bidi
            = new Bidi(
                "TE1",
                Bidi.DIRECTION_RIGHT_TO_LEFT);
  
        // getting the internal state of bidi
        // using toString() method
        String status = bidi.toString();
  
        // display the result
        System.out.println(
            "status of bidi : "
            + status);
    }
}


Output:

status of bidi :
 sun.text.bidi.BidiBase[
  dir: 2
  baselevel: 1
  length: 3
  runs: [2 2 2]
  text: [0x54 0x45 0x31]]

Reference: https://docs.oracle.com/javase/9/docs/api/java/text/Bidi.html#toString–



Last Updated : 27 Nov, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads