Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

how to find the length of a string in java without using length function

public class StringLength {
   public static void main(String args[]) throws Exception {
      String str = "sampleString";
      int i = 0;
      for(char c: str.toCharArray()) {
         i++;
      }
      System.out.println("Length of the given string ::"+i);
   }
}
Source by www.tutorialspoint.com #
 
PREVIOUS NEXT
Tagged: #find #length #string #java #length #function
ADD COMMENT
Topic
Name
5+3 =