Skip to content

Instantly share code, notes, and snippets.

@mattiaferigutti
Last active March 21, 2017 17:24
Show Gist options
  • Save mattiaferigutti/449be43b95e185d61f202e4d48997045 to your computer and use it in GitHub Desktop.
Save mattiaferigutti/449be43b95e185d61f202e4d48997045 to your computer and use it in GitHub Desktop.
polindroma
/**
* Created by Mattia on 20/03/2017.
*/
public class PolindromaClass
{
private String stringa;
public PolindromaClass(String stringa)
{
this.stringa = stringa;
}
public void Verifica()
{
String s = "";
for (int i=0; i<=stringa.length()-1; i++)
{
s = s + stringa.charAt(i);
}
System.out.println("non polindroma: " + s);
String inv = "";
for (int i=stringa.length()-1; i>=0; i--)
{
inv = inv + stringa.charAt(i);
}
System.out.println("polindroma: " + inv);
//verifica stringhe
if (inv.equals(s))
{
System.out.println("\nsono polindrome");
}
else {
System.out.println("\nnon sono polindrome");
}
}
}
public class PolindromaMain
{
public static void main(String args[])
{
PolindromaClass pol = new PolindromaClass("tollot");
pol.Verifica();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment