Skip to content

Instantly share code, notes, and snippets.

@nherbaut
Created October 5, 2023 10:51
Show Gist options
  • Save nherbaut/a00e413d8ae6563376065d3bc5906165 to your computer and use it in GitHub Desktop.
Save nherbaut/a00e413d8ae6563376065d3bc5906165 to your computer and use it in GitHub Desktop.
L2.3.4 Diverses fonctions de la classe String
true
true
true
true
true
true
true
true

Remplacez les ? par les bonnes réponses

public class StringSubString{
public static void main(String... args){
String s = "sorbonnepantheonMIASHS";
String resp1 = s.substring(8,16);
String myGuess1="pantheon"; // Réponse ici
int resp2 = s.length();
int myGuess2 = ?;// Réponse ici
int resp3 = s.indexOf("bonne");
int myGuess3 = ?;// Réponse ici
int resp4 = s.indexOf("n");
int myGuess4 = ?;// Réponse ici
int resp5 = s.indexOf("CRI");
int myGuess5 = ?;// Réponse ici
int resp6 = s.indexOf("n",7);
int myGuess6 = ?;// Réponse ici
boolean resp7 = s.startsWith("sorbonne");
boolean myGuess7 = ?;// Réponse ici
boolean resp8 = s.endsWith("L1");
boolean myGuess8 = ?;// Réponse ici
System.out.println(resp1.equals(myGuess1));
System.out.println(resp2==myGuess2);
System.out.println(resp3==myGuess3);
System.out.println(resp4==myGuess4);
System.out.println(resp5==myGuess5);
System.out.println(resp6==myGuess6);
System.out.println(resp7==myGuess7);
System.out.println(resp8==myGuess8);
}
}
@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