Open In App

TextStyle isStandalone() method in Java with Examples

The isStandalone() method of TextStyle enum is used to return true if the TextStyle is a stand-alone style.

Syntax:



public TextStyle isStandalone()

Parameters: This method accepts nothing.

Return value: This method returns true if the style is a stand-alone style.



Below programs illustrate the TextStyle.isStandalone() method:
Program 1:




// Java program to demonstrate
// TextStyle.isStandalone() method
  
import java.time.format.TextStyle;
  
public class GFG {
    public static void main(String[] args)
    {
  
        // get TextStyle
        TextStyle style
            = TextStyle.valueOf(
                "SHORT_STANDALONE");
  
        // apply isStandalone()
        boolean isStandaloneAttribute
            = style.isStandalone();
  
        // print
        System.out.println(
            "TextStyle is Standalone:"
            + isStandaloneAttribute);
    }
}

Output:
TextStyle is Standalone:true

Program 2:




// Java program to demonstrate
// TextStyle.isStandalone() method
  
import java.time.format.TextStyle;
  
public class GFG {
    public static void main(String[] args)
    {
  
        // get TextStyle
        TextStyle style
            = TextStyle.valueOf("FULL");
  
        // apply isStandalone()
        boolean isStandaloneAttribute
            = style.isStandalone();
  
        // print
        System.out.println(
            "TextStyle is Standalone:"
            + isStandaloneAttribute);
    }
}

Output:
TextStyle is Standalone:false

References: https://docs.oracle.com/javase/10/docs/api/java/time/format/TextStyle.html#isStandalone()


Article Tags :