Answers for "ispalindrome java"

2

palindrome function java

package test
//The function below checks if a string is a palindrome
//True = Is a palindrome & False = Not a palindrome
	public boolean isPalindromString(String text){
    	String reverse = reverse(text);
      	if(text.equals(reverse))
    	{
        	return true;
      	}
      
      	return false;
    }
//This function returns the reverse String of its input.
//Ex. if given "hello", it will return "olleh"
	public String reverse(String input)
    {     
		if(input == null || input.isEmpty())
        {
			return input;
        }
        	return input.charAt(input.length()- 1) + reverse(input.substring(0, input.length() - 1));
    }
Posted by: Guest on June-18-2020
0

palindrome in java

package test
//The function below checks if a string is a palindrome
//True = Is a palindrome & False = Not a palindrome
	public boolean isPalindromString(String text){
    	String reverse = reverse(text);
      	if(text.equals(reverse))
    	{
        	return true;
      	}
      
      	return false;
    }
//This function returns the reverse String of its input.
//Ex. if given "hello", it will return "olleh"
	public String reverse(String input)
    {     
		if(input == null || input.isEmpty())
        {
			return input;
        }
return input.charAt(input.length()- 1) + reverse
                         (input.substring(0, input.length() - 1));
    }
Posted by: Guest on January-14-2021
0

ispalindrome function java

import java.util.Scanner;

public class iSPALINDROME {

        public static void main(String[] argh){
            System.out.print("Enter some integer: ");
            Scanner input = new Scanner(System.in);
            String n = input.next();
            Ispalindrome(n);
            input.close();

        }
        public static boolean Ispalindrome(String s) {
            int length = s.length();
            int i = 0;
            int midle = (s.length() / 2);
            boolean ispalindrome = true;
            int k = length-1;
            for (int j = 0; j <= midle& k>=midle; ++j,--k) {
                if(j==0 & s.charAt(j)=='-'){
                    ++j;
                }
                if (s.charAt(j) == s.charAt(k)){
                    ispalindrome = true;

                }else{ispalindrome = false;break;}
            }return print(ispalindrome);
        }

        public static boolean print(boolean ispalindrome){
            System.out.println(ispalindrome);
            return true;
        }



}
Posted by: Guest on July-14-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language