Answers for "chararray length"

0

chararray length

import java.util.Scanner;

public class FindLengthOfStringWithoutUsingLength {

	public static void main(String[] args) {
		int length=0;
		Scanner sc = new Scanner(System.in);
		System.out.println("Enter a String");
        String s = sc.next();
        for (char c1 : s.toCharArray()) 
			length++;
		System.out.println("Length of String is : "+length);
		
	}

}
This code is contributed by Shubham Nigam (Prepinsta Placement Cell Student)
Posted by: Guest on June-10-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language