Version without JavaScript, read-only: workshops, quizzes and running code are not available here. Full version · Catalogue · Sign in
Sequence
Length of a string
Core exercise
Write longueur(String texte) that returns the number of characters in the string.
A workshop goes here: you write and run code in it. It requires JavaScript.
Starting code
Exercices.java
public class Exercices {
public static void main(String[] args) {
System.out.println(longueur("bonjour"));
}
public static int longueur(String texte) {
// TODO
return 0;
}
}
The core exercise is validated in the workshop, which requires JavaScript.
Hint 1
For a string it is length(), a method, with parentheses. For an array it is length, without parentheses. This difference is a classic exam question.