Java String codePointBefore() Method

You are Here:

Java String codePointBefore()

The codePointBefore() method returns the Unicode value of the character before the given index in a string.

The index number starts from 0 and goes to n-1, where n is length of the string.

Example

Java Compiler
public class myClass { public static void main(String[] args) { String str = "Apple"; System.out.print(str.codePointBefore(1)); // 65 } }

Output

65

Syntax

public int codePointBefore(int index)

Parameter Values

ValueTypeExplanation
indexRequiredSpecifies an index number.

Return Value

ValueExplanation
NumberReturns the Unicode value of the character before the given index in a string.
ErrorReturns StringIndexOutOfBoundsException, if index number is less than 1 or greater than the length of the given string.

Reminder

Hi Developers, we almost covered 90% of String functions and Interview Question on Java with examples for quick and easy learning.

We are working to cover every Single Concept in Java.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author