I'm a 1st College student with no prior coding experience. I'm working on a text editor for my second assignment. One of the many features of this text editor is the ability to count the number of characters in a string, and, since this is a string array, there are multiple of them. Here's what I've got thus far:
int maxSize=100;
int [] nChars = new int[maxSize];
String [] linhas = new String[maxSize];
for (int i=0; i<maxSize;i++){
nChars[i]=lines[i].charAt(i);
System.out.println(lines[i]+ " - " + nChars[i]); \\print the line and the respective number of characters
Any help is apreciated, I'm pretty much stuck.
The functions you are searching for is simply the .legth() function which will return the numbers of characters in a String.
String myString = "testString";
System.out.println("The string has " + myString.length() + " characters");
// output: The string has 10 characters
If you have an array of strings then just iterate through it and use the length() function on each element.
Greetings Raven