assignez à responseIndex
l'index du premier char en minuscule rencontré après avoir rencontré pour la première fois une majuscule
Created
October 5, 2023 09:37
-
-
Save nherbaut/815d56f4b61b756c3675c189faf92504 to your computer and use it in GitHub Desktop.
L2.3.2 Strings en tant que tableau de char
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExStringCharArray{ | |
public static void main(String... args){ | |
int responseIndex=0; | |
char[] messageAsChars = "sorbonnepantheonMIASHSl2".toCharArray(); | |
for(int i = 0; i<messageAsChars.length; i++){ | |
if(Character.isUpperCase(messageAsChars[i])){ | |
System.out.println(i+" est le premier index qui contient une majuscule"); | |
break; | |
} | |
} | |
System.out.println(responseIndex+" est le premier index qui contient une minuscule après une majuscule"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
execute me on https://java.miage.dev/?gistId=815d56f4b61b756c3675c189faf92504