Languages
[Edit]
EN

Java - how to check string length?

0 points
Created by:
Sylvie-Justice
280

In Java it is possible to check string length in following way.

1. String length() method example

public class StringExample {

    public static void main(String[] args) {
        String text = "This is my text...";
        String anotherText = "Another text...";

        System.out.println(text.length()); // 18
        System.out.println(anotherText.length()); // 15 
    }
}

Output:

18
15

Java - String (popular problems)

Java - how to check string length?
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join