Print Length of each input String.

Print Length of each input String.


Description:- 

This program takes input as test cases where we will be giving in multiple strings as a input and for them we need return length of those strings on each line.

Code:-



import java.lang.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int testCases = sc.nextInt();

        for(int i=0; i<testCases;i++){
            String str = sc.next();

            int length = str.length();

            System.out.println(length);
        }
        
    }
}




P.S.:- If you have any feedback or do you want any improvement in this post do mention in comment.

    

Comments

Popular Posts