Wednesday, July 3, 2024
HomeLanguagesJavaBidi createLineBidi() method in Java with Examples

Bidi createLineBidi() method in Java with Examples

The createLineBidi() method of java.text.Bidi class is used to create a new bidi object having same base direction and representing every property of current bidi within the range.

Syntax:

public Bidi createLineBidi(int lineStart,
                           int lineLimit)

Parameter: This method takes following argument as parameter

  • lineStart: it is the start point of this new bidi
  • lineLimit: it is the end point for this new bidi

Return Value: This method return a new Bidi object

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

Example 1:




// Java program to demonstrate
// createLineBidi() method
  
import java.text.*;
import java.util.*;
import java.io.*;
  
public class GFG {
    public static void main(String[] argv)
    {
        // creating and initializing Bidi
        // text with base direction
        Bidi bidi
            = new Bidi(
                "Geeks For Geeks",
                Bidi.DIRECTION_RIGHT_TO_LEFT);
  
        // creating and new bidi Object using the old one
        // using createLineBidi() method
        Bidi newbidi = bidi.createLineBidi(1, 6);
  
        // display the new bidi status
        System.out.println("New Bidi "
                           + "\nLength : "
                           + newbidi.getLength()
                           + "\nnumber of levels : "
                           + newbidi.getRunCount()
                           + "\nBase Level : "
                           + newbidi.getBaseLevel());
    }
}


Output:

New Bidi 
Length : 5
number of levels : 2
Base Level : 1

Example 2:




// Java program to demonstrate
// createLineBidi() method
  
import java.text.*;
import java.util.*;
import java.io.*;
  
public class GFG {
    public static void main(String[] argv)
    {
        // creating and initializing Bidi
        // text with base direction
        Bidi bidi
            = new Bidi("Tajmahal",
                       Bidi.DIRECTION_RIGHT_TO_LEFT);
  
        // creating and new bidi Object using the old one
        // using createLineBidi() method
        Bidi newbidi = bidi.createLineBidi(3, 5);
  
        // display the new bidi status
        System.out.println("New Bidi "
                           + "\nLength : "
                           + newbidi.getLength()
                           + "\nnumber of levels : "
                           + newbidi.getRunCount()
                           + "\nBase Level : "
                           + newbidi.getBaseLevel());
    }
}


Output:

New Bidi 
Length : 2
number of levels : 1
Base Level : 2

Reference: https://docs.oracle.com/javase/9/docs/api/java/text/Bidi.html#createLineBidi-int-int-

Nokonwaba Nkukhwana
Experience as a skilled Java developer and proven expertise in using tools and technical developments to drive improvements throughout a entire software development life cycle. I have extensive industry and full life cycle experience in a java based environment, along with exceptional analytical, design and problem solving capabilities combined with excellent communication skills and ability to work alongside teams to define and refine new functionality. Currently working in springboot projects(microservices). Considering the fact that change is good, I am always keen to new challenges and growth to sharpen my skills.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments