-
Python:
def is_length_greater_than(string, length): return len(string) > length # Example usage text = "Hello, world!" if is_length_greater_than(text, 10): print("The length of the string is greater than 10.") else: print("The length of the string is not greater than 10.")
-
JavaScript:
function isLengthGreaterThan(string, length) { return string.length > length; } // Example usage var text = "Hello, world!"; if (isLengthGreaterThan(text, 10)) { console.log("The length of the string is greater than 10."); } else { console.log("The length of the string is not greater than 10."); }
-
Java:
public class StringLengthChecker { public static boolean isLengthGreaterThan(String string, int length) { return string.length() > length; } // Example usage public static void main(String[] args) { String text = "Hello, world!"; if (isLengthGreaterThan(text, 10)) { System.out.println("The length of the string is greater than 10."); } else { System.out.println("The length of the string is not greater than 10."); } } }
-
C#:
public class StringLengthChecker { public static bool IsLengthGreaterThan(string str, int length) { return str.Length > length; } // Example usage public static void Main(string[] args) { string text = "Hello, world!"; if (IsLengthGreaterThan(text, 10)) { Console.WriteLine("The length of the string is greater than 10."); } else { Console.WriteLine("The length of the string is not greater than 10."); } } }