Bidi toString() method in Java with Examples

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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);
    }
}

chevron_right


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:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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);
    }
}

chevron_right


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–

Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.