How to find length of a string without using . length () function?
Plz answer in Blue Java.
Answers
Answered by
6
import java.util.*;
class Brainly
{
public static void main(String[] args)
{
String word;
int i=0;
System.out.println("Enter a word:");
Scanner demo = new Scanner(System.in);
word=demo.nextLine();
for(char ch:word.toCharArray())
{
i++;
}
System.out.println("The number is:" +i);
}
}
Hope this helps!
class Brainly
{
public static void main(String[] args)
{
String word;
int i=0;
System.out.println("Enter a word:");
Scanner demo = new Scanner(System.in);
word=demo.nextLine();
for(char ch:word.toCharArray())
{
i++;
}
System.out.println("The number is:" +i);
}
}
Hope this helps!
Attachments:
siddhartharao77:
Mark as brainliest.
Similar questions