What is substring(int beginIndex) in Groovy?

substring(int beginIndex) is a Groovy function that pads a string with the spaces added to the right.

Syntax


String substring(int Index)

Parameters

The function takes in one parameter, Index. This is the beginning index.

Return value

The function returns the specified substring.

Code

class Main {
static void main(String[] args) {
String result = "Edpresso";
println(result.substring(4));
}
}

Output


esso
New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources