In java it can be done through the reflection api.

Have a look at Class.getMethod(String methodName, Class... parameterTypes).

A complete example (of a non-static method with an argument) would be:

import java.lang.reflect.*;
public class Test {

    public String methodName(int i) {
        return "Hello World: " + i;
    }

    public static void main(String... args) throws Exception {
        Test t = new Test();
        Method m = Test.class.getMethod("methodName", int.class);
        String returnVal = (String) m.invoke(t, 5);
        System.out.println(returnVal);
    }
}

Which outputs:

Hello World: 5

Answer from aioobe on Stack Overflow
🌐
W3Schools
w3schools.com › java › java_ref_string.asp
Java String Methods
assert abstract boolean break byte case catch char class continue default do double else enum exports extends final finally float for if implements import instanceof int interface long module native new package private protected public return requires short static super switch synchronized this throw throws transient try var void volatile while Java String Methods
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › String.html
String (Java Platform SE 8 )
October 20, 2025 - The Java language provides special support for the string concatenation operator ( + ), and for conversion of other objects to strings. String concatenation is implemented through the StringBuilder(or StringBuffer) class and its append method. String conversions are implemented through the ...
Discussions

Calling a method named "string" at runtime in Java and C - Stack Overflow
How can we call a method which name is string at runtime. Can anyone show me how to do that in Java and C. More on stackoverflow.com
🌐 stackoverflow.com
Java String Methods - You Need To Know

First method of the article is charAt... Great start! Then you realise this is probably every method available order alphabetically... This could be reduce to a "5 methods to know" to be really interesting.

More on reddit.com
🌐 r/programming
1
0
May 14, 2015
ELI5:What is a "String" in Java/programming and why is it known as a "complex added type" and other variable are known as "primitive" ?
In simplest terms, a String is an collection (referred to in programming as an "array") of characters. If you wanted to have a String that said "Reddit", it would literally be an array of character values ['R', 'e', 'd', 'd', 'i', 't']. The most fundamental difference between strings and primitive types such as "int" are that primitives are single values. Strings are collections of values (specifically, a collection of characters.) Characters themselves are primitive types. In addition, primitive types are pieces of data. Strings are objects, which are instances of classes. As far as classes go...basically, the people who made Java built a lot of code so Strings could be easy to use by programmers. (This is also why "String" is capitalized: the name of the class has a capital S.) Sorry if this is too technical...but it should answer your questions. More on reddit.com
🌐 r/explainlikeimfive
5
1
November 21, 2015
New Methods on Java Strings With JDK 11

Looks like they're taking the awful PHP "real_escape_string" approach to API development of finding increasingly strained synonyms when something needs to be fixed by making the Unicode-aware version of String.trim() be named String.strip() instead of just adding an overload for trim() that takes an option parameter to specify the trimming type.

A hypothetical alternative of trim(StringTrimOptions options), used as in these examples:

// First two are equivalent, and use the backward-compatible
// pre-existing trimming logic
str.trim();
str.trim(StringTrimOptions.ASCII_WHITESPACE);

// This example uses new Unicode-compatible trimming logic.
str.trim(StringTrimOptions.UNICODE_WHITESPACE);

... would be a much better solution that wouldn't require every developer going forward, in perpetuity, to have to discover what the non-obvious difference between trim() and strip() is (whereas the hypothetical StringTrimOptions alternative is self-explanatory to a large extent); and is forward-compatible should the need ever arise in the future for yet another type of string trimming.

(And with the isBlank() method being added too, which could probably also benefit from being able to specify the type of whitespace; maybe instead of StringSplitOptions the argument should be WhitespaceType instead so an overload ofisBlank() could read correctly with it too.)

More on reddit.com
🌐 r/programming
16
30
December 3, 2014
🌐
Medium
beknazarsuranchiyev.medium.com › string-class-and-its-methods-in-java-147b7aedc3a9
String class and its methods in Java | by Beknazar | Medium
June 15, 2022 - String class and its methods in Java java.lang.String is the most used class in Java. It’s important to understand and be able to manipulate strings fluently. String Class String Methods Comparing …
🌐
DEV Community
dev.to › pankaj_singhr › 10-most-useful-string-methods-in-java-4lag
🎯 10 most useful string methods in Java - DEV Community
January 19, 2022 - 1 - indexOf() used to find characters and substrings in a string. It returns the index of first occurrence from left of the passed string or character syntax - public int indexOf​(String str, int fromIndex) str - substring to be search fromIndex - search begin from this index
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-string-methods
Java String Methods - GeeksforGeeks
October 11, 2025 - Java provides a rich set of String methods that help perform various operations like comparison, searching, modification of string.
Find elsewhere
🌐
Refreshjava
refreshjava.com › java › string-class-methods
Useful String Class Methods in Java with Example - RefreshJava
Java string class methods are used to perform operations on string variables or string literals like compare two strings, find or replace a character/word in a string, add two strings etc.
🌐
Quora
quora.com › What-is-string-in-Java-3
What is string in Java? - Quora
Answer (1 of 5): It is a data type that stores values in text format. It is assigned to a variable to tell the compiler that this variable will store data in text format. That variable is then called a string variable.
🌐
Scribd
scribd.com › document › 83328637 › String-Methods-in-Java
Java String Methods Overview | PDF
JavaScript is disabled in your browser · Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
Runestone Academy
runestone.academy › ns › books › published › csjava › Unit2-Using-Objects › topic-2-7-string-methods.html
2.7. String Methods — CS Java
Trying to call a method like indexOf on a string reference that is null. You will get a null pointer exception. Using == to test if two strings are equal. This is actually a test to see if they refer to the same object. Usually you only want to know if they have the same characters in the same order. In that case you should use equals or compareTo instead. Treating upper and lower case characters the same in Java.
🌐
Tutorialspoint
tutorialspoint.com › home › java › java strings
Java Strings
September 1, 2008 - Note − The String class is immutable, so that once it is created a String object cannot be changed. If there is a necessity to make a lot of modifications to Strings of characters, then you should use String Buffer & String Builder Classes. Methods used to obtain information about an object are known as accessor methods.
🌐
Quizlet
quizlet.com › 711022570 › java-string-methods-flash-cards
Java String Methods Flashcards | Quizlet
The Java platform provides the String class to create and manipulate strings example: String word = "dog"; Method · A Java method is a collection of statements that are grouped together to perform an operation ·
🌐
ScholarHat
scholarhat.com › home
What is String in Java - Java String Methods & Type (Examples)
Strings are immutable, meaning once created, their values cannot be changed. Java provides powerful built-in methods for string manipulation, such as concatenation, comparison, substring extraction, and pattern matching.
Published   August 30, 2025
🌐
Tutorial Gateway
tutorialgateway.org › java-string-methods
Java String methods
March 28, 2025 - The String Methods perform string comparison, search, copy, extracting substring, and converting to lowercase or uppercase. The following table shows the list of Java Methods or functions available in the String Class
🌐
Quora
quora.com › What-are-the-string-functions-in-Java
What are the string functions in Java? - Quora
Answer (1 of 3): I do not understand the question. First of all Java does not have functions but methods. This means that standalone functions, like in C, C++ and other languages, simply do not exist and in Java a method is always bound to a class. Static methods are somewhat different, but they ...
🌐
Tutorialspoint
tutorialspoint.com › home › java/lang › java string class
Java String Class
September 1, 2008 - Note − The String class is immutable, so that once it is created a String object cannot be changed. If there is a necessity to make a lot of modifications to Strings of characters, then you should use String Buffer & String Builder Classes. Methods used to obtain information about an object are known as accessor methods.
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-programming-interview-questions
Top Java Coding Interview Questions (With Answers) | DigitalOcean
April 17, 2025 - All the string manipulation methods return a new string, which is why you need to assign it to another variable. Learn more about removing characters from a string in Java.
🌐
Engineer\'s Portal
er.yuvayana.org › home › java › string class methods in java
String class methods in Java
December 22, 2022 - In Java, a String is a pre-defined class that is present in java.lang package. This class is final which implies that no class can extend this. The string class is also immutable.
🌐
Dremendo
dremendo.com › java-programming-tutorial › java-string
String in Java Programming | Dremendo
The compareTo() method compares two strings lexicographically · including case sensitive comparison. It returns a negative value if the first string is less then the second string. A positive value if the first string is greater than the second string. It returns zero if both are same. import java.util.Scanner; public class StringMethod { public static void main(String args[]) { String s1,s2; Scanner sc=new Scanner(System.in); System.out.println("Enter 2 strings"); s1=sc.nextLine(); s2=sc.nextLine(); if(s1.compareTo(s2)==0) { System.out.println("Both are same string"); } else { System.out.println("They are not same"); } } }
🌐
Great Learning
mygreatlearning.com › blog › it/software development › string manipulation in java
String Manipulation in Java
June 30, 2025 - String substring(int beginIndex): This method helps to return a substring from the string.