by @kodeazy
flutter what is Palindrome and example program to check String is Palindrome or not in dart?
- If reverse of String is same as the String then the String is
Palindrome
. - For Example:
cbbc
is palindrome because reverse is alsocbbc
.
import 'package:flutter/material.dart';
void main() {
String stringToReverse = "acca";
String reversedString = "";
String beforeReverse = stringToReverse;
for (int j = stringToReverse.length - 1; j >= 0; j--) {
reversedString += stringToReverse[j];
}
print("Reversed String is");
print(reversedString);
if (beforeReverse == reversedString) {
print("String is Palindrome");
} else {
print("String is not Palindrome");
}
}
Output
:
Number is Palindrome