How to Find String Length in Java Program

How to Find String Length in Java Program

Here you will get program code to find string length in java program by using 2 different ways.

1. using length() method

2. without using length() method

Program to Find String Length in Java Program using length()

Output

C:\CodeRevise\java>javac FindStringLength.java

C:\CodeRevise\java>java FindStringLength
Enter a string : Coderevise.com
The length of the string is: 14

 

Find String Length in Java Program without using length()

Output

C:\CodeRevise\java>javac FindStringLength.java

C:\CodeRevise\java>java FindStringLength
Enter a string : Welcome to Code Revise
The length of the string is: 22

 

 

 

Check out our other Java Programming Examples

 

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top