Search
 
SCRIPT & CODE EXAMPLE
 

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);
   }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java extract zip 
Java :: get minimum of array java 
Java :: 64 bit integer java 
Java :: No Java files found that extend CordovaActivity. [ERROR] An error occurred while running subprocess cordova. 
Java :: how to get current date in java 
Java :: java enum length 
Java :: android-edittext allow only characters and numbers 
Java :: java booleans 
Java :: android studio change launcher icon 
Java :: check if list includes value java 
Java :: javafx textarea size 
Java :: find length of array java 
Java :: classcastexception in java 
Java :: Cause: zip END header not found 
Java :: java throw keyword 
Java :: android studio edittext enter pressed 
Java :: string length in android studio java 
Java :: is palindrome java 
Java :: java regex case insensitive 
Java :: raise error java 
Java :: java new char array 
Java :: java sql query with parameters 
Java :: java turn string into int 
Java :: Java for and while loops 
Java :: greater than sign in java 
Java :: java string literals 
Java :: how to get string from resource id android 
Java :: android setTextColor not working 
Java :: what is a do while loop in java 
Java :: Java Create an OutputStream 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =