Bonjour à tous !
Je voudrais inverser l'ordre des mots
pour tester le fait qu'il s'agisse d'un palindrome ou non ...
je souhaite utiliser la méthode StringBuffer reverse
mais je ne comprends pas bien comment l'utiliser( les explications
de la doc java ne m'éclaire guère !)
Merci d'avance pour vos explications et conseils![]()
JeanMarc
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 public class Palindrome { public static void main ( String args[]){ Palindrome a = new Palindrome(); a.palindrome1(); //a.palindrome2(); a.palindrome3(); a.palindrome4(); a.palindrome5(); } String test="coucou"; public String palindrome1(){ return(test); } public String palindrome2(String test){ String envers; //StringBuffer palin= new StringBuffer(); // envers=palin.reverse(test); return (envers); } public String palindrome3(){ return(test);} public String palindrome4(){ return(test);} public String palindrome5(){ return(test);} }
Partager