SHARE
TWEET

palindrome

a guest Sep 11th, 2019 97 in 174 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.     System.out.print("Ange ett ord eller en mening: ");
  9.     Scanner scan = new Scanner(System.in);
  10.     String texten = scan.nextLine();
  11.     if (texten.equalsIgnoreCase(reverseString(texten))){
  12.         System.out.print("Palindrom");
  13.     }
  14.     }
  15.     public static String reverseString(String str) {
  16.         StringBuilder sb = new StringBuilder(str);
  17.         sb.reverse();
  18.         return sb.toString();
  19.     }
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top