Home » Java programming language

Java StringBuffer int codePointBefore(int index) method with Example

Java StringBuffer int codePointBefore(int index) method: Here, we are going to learn about the int codePointBefore(int index) method of StringBuffer class with its syntax and example.
Submitted by Preeti Jain, on June 29, 2019

StringBuffer Class int codePointBefore(int index)

  • This method is available in package java.lang.StringBuffer.codePointBefore(int index).
  • This method is used to return the Unicode character value (Unicode Codepoint) before at the specified index (i.e. it returns Unicode codepoint before one position of the specified index) in the method.
  • Index range will start from 0 to length()-1.
  • This method does not raise an exception.

Syntax:

    int codePointBefore(int index){
    }

Parameter(s):

We can pass only one object in the method of the StringBuffer i.e index.

Return value:

The return type of this method is int that means this method return Unicode codepoint of the character before one position at the given index and codepoint value is in number format.

Java program to demonstrate example of codePointBefore(int index) method

import java.lang.StringBuffer;

public class StringBufferClass {
    public static void main(String[] args) {

        StringBuffer sb = new StringBuffer("Java is a programming language : ");

        // use codePointAt(int index) it will return Unicode codepoint 
        // of the character before at the specified index

        // Display result after implementing codePointBefore(2)

        System.out.println("The result will be after implementing method codePointBefore(2) is :" + sb.codePointBefore(2));

        sb = new StringBuffer("Java Support OOPS Concept");

        //use codePointBefore(int index) it will return Unicode codepoint 
        // of the character before at the specified index

        //Display result after implementing codePointBefore(5)

        System.out.println("The result will be after implementing method codePointBefore(5) is :" + sb.codePointBefore(5));
    }
}

Output

D:\Programs>javac StringBufferClass.java

D:\Programs>java StringBufferClass
The result will be after implementing method codePointBefore(2) is :97
The result will be after implementing method codePointBefore(5) is :32





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.
Learn PCB Designing: PCB DESIGNING TUTORIAL







Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.