Skip to content

Instantly share code, notes, and snippets.

@nherbaut
Created October 5, 2023 09:37
Show Gist options
  • Save nherbaut/815d56f4b61b756c3675c189faf92504 to your computer and use it in GitHub Desktop.
Save nherbaut/815d56f4b61b756c3675c189faf92504 to your computer and use it in GitHub Desktop.
L2.3.2 Strings en tant que tableau de char

assignez à responseIndex l'index du premier char en minuscule rencontré après avoir rencontré pour la première fois une majuscule

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");
}
}
@nherbaut
Copy link
Author

nherbaut commented Oct 5, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment