Click here to Skip to main content
15,906,645 members
Home / Discussions / Java
   

Java

 
AnswerRe: Block desktop until app running? Pin
TorstenH.23-Feb-11 20:07
TorstenH.23-Feb-11 20:07 
AnswerRe: Block desktop until app running? Pin
jschell24-Feb-11 11:59
jschell24-Feb-11 11:59 
GeneralRe: Block desktop until app running? Pin
Alok Sharma ji24-Feb-11 20:32
Alok Sharma ji24-Feb-11 20:32 
QuestionRecursion:Delete from a linkedList Pin
Brian Robertson21-Feb-11 22:08
Brian Robertson21-Feb-11 22:08 
AnswerRe: Recursion:Delete from a linkedList Pin
Nagy Vilmos22-Feb-11 1:44
professionalNagy Vilmos22-Feb-11 1:44 
AnswerRe: Recursion:Delete from a linkedList Pin
David Skelly22-Feb-11 1:50
David Skelly22-Feb-11 1:50 
QuestionPalindrome assignment Pin
Chuon Visoth21-Feb-11 14:04
Chuon Visoth21-Feb-11 14:04 
AnswerRe: Palindrome assignment Pin
shivamkalra21-Feb-11 15:21
shivamkalra21-Feb-11 15:21 
I found few mistakes. I've commented them and your program is working fine..

import java.util.Scanner;

public class firstsubroutine {
	public static void main (String[] args){
	    
		Scanner in = new Scanner(System.in);
        System.out.println("Enter the palindrome : ");
        System.out.println("? ");
        String line = in.next();    
        line = line.toLowerCase();

        if (isString(line) == true){
            //no need for this
        	//reverse(line);
            String reversed = reverse(line);
            
            //changed "==" to equals
            if (line.equals(reversed)){
                System.out.println ("Stripped : " + line);
                System.out.println ("Reversed : " + reversed);
                System.out.println ("This IS a palindrome.");
            }
            else{
                System.out.println ("Stripped : " + line);
                System.out.println ("Reversed : " + reversed);
                System.out.println ("This is NOT a palindrome.");
        }
        }  
    }

    // isString subroutine
    //return boolean
    static /*void*/boolean isString (String isStr){
    
        int i;
        
        //dont really need it
       // boolean isBoolean;
        
        for (i = 0; i < isStr.length(); i++){
            char ch =  isStr.charAt(i);
            //if (Character.isLetter(ch)){
                //isBoolean = true;        
            //}
            if (!Character.isLetter(ch))
            {
            	//not really a mistake
            	// but when its not letter than you are sure that
            	//it is not a string so return false quickly
                //isBoolean = false;
                
                return false;
            }
        }
        
        return true;
    }
    
    // reverse subroutine
    // u need to return string
    static /*void*/String reverse(String reStr){
    
        int i;
        String reverse = "";
        // try to FOLLOW THE LOOP
        for (i = reStr.length() - 1; i >= 0; i--/*++*/){
            reverse = reverse + reStr.charAt(i);
        }
        
        return reverse;
    }
}

Shivam Kalra

GeneralRe: Palindrome assignment Pin
Chuon Visoth21-Feb-11 15:36
Chuon Visoth21-Feb-11 15:36 
GeneralRe: Palindrome assignment Pin
shivamkalra21-Feb-11 15:41
shivamkalra21-Feb-11 15:41 
GeneralRe: Palindrome assignment Pin
Chuon Visoth21-Feb-11 15:45
Chuon Visoth21-Feb-11 15:45 
GeneralRe: Palindrome assignment Pin
shivamkalra21-Feb-11 15:48
shivamkalra21-Feb-11 15:48 
GeneralRe: Palindrome assignment Pin
Chuon Visoth21-Feb-11 15:50
Chuon Visoth21-Feb-11 15:50 
GeneralRe: Palindrome assignment Pin
shivamkalra21-Feb-11 15:54
shivamkalra21-Feb-11 15:54 
AnswerRe: Palindrome assignment Pin
TorstenH.21-Feb-11 20:48
TorstenH.21-Feb-11 20:48 
GeneralRe: Palindrome assignment Pin
Chuon Visoth23-Feb-11 13:37
Chuon Visoth23-Feb-11 13:37 
GeneralRe: Palindrome assignment Pin
TorstenH.23-Feb-11 19:34
TorstenH.23-Feb-11 19:34 
QuestionDeveloping Lotus Notes Plugin : What does "navigate to the JRE in the Notes installation folder" means? Pin
eight20-Feb-11 16:23
eight20-Feb-11 16:23 
AnswerRe: Developing Lotus Notes Plugin : What does "navigate to the JRE in the Notes installation folder" means? Pin
Richard MacCutchan21-Feb-11 0:47
mveRichard MacCutchan21-Feb-11 0:47 
GeneralRe: Developing Lotus Notes Plugin : What does "navigate to the JRE in the Notes installation folder" means? Pin
eight21-Feb-11 16:22
eight21-Feb-11 16:22 
GeneralRe: Developing Lotus Notes Plugin : What does "navigate to the JRE in the Notes installation folder" means? Pin
Richard MacCutchan21-Feb-11 21:54
mveRichard MacCutchan21-Feb-11 21:54 
QuestionUtility calling Java application Pin
Indrojeet18-Feb-11 20:17
Indrojeet18-Feb-11 20:17 
AnswerRe: Utility calling Java application Pin
jschell19-Feb-11 9:10
jschell19-Feb-11 9:10 
GeneralRe: Utility calling Java application Pin
Indrojeet20-Feb-11 17:47
Indrojeet20-Feb-11 17:47 
GeneralRe: Utility calling Java application Pin
TorstenH.20-Feb-11 21:33
TorstenH.20-Feb-11 21:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.