Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class palin
- {
- public static void main ( String args[] )
- {
- Scanner input = new Scanner ( System.in );
- String word;
- String arr;
- String arr2;
- int count;
- //prompt for word and set word to word
- System.out.print ( "word: " );
- word = input.next();
- //set count to word length
- count = word.length() - 1;
- //set the word equal to two dummy vars
- arr = arr2 = word;
- //loop as large as word
- for ( int i = 0; i < count; ++i )
- {
- //if one char isn't equal to another, break
- if ( arr.charAt(i) != arr2.charAt(count--) )
- {
- System.out.println ( "not palin bro" );
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement