943,808 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1799
  • Java RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Dec 18th, 2008
0

Re: Palindromes

When I said, 'Where ... refers to the code after the line String s = inFile.readLine();' I meant all of the code. A loop will allow for a set of instructions to be executed 0, 1 or more times. If all you want to repeat is reading the data from the file, then that leaves you with only processing the last line of the file.

You need to read in the data and process it and that's what needs to be repeated and thus placed in a loop.

Anyway, what do you mean by, 'at the start of my boolean?' Please use the [code=java] so line numbers appear. That way you can tell us which line the error occurred. The expression in the while loop is not incorrect and would compile.

Regardless, by looking at your code I can see that you're missing some braces. Particularly, you don't close the for loop nor do you close the main method. This is why you're getting the error.
Last edited by PoovenM; Dec 18th, 2008 at 9:49 am.
Reputation Points: 56
Solved Threads: 11
Junior Poster
PoovenM is offline Offline
147 posts
since Aug 2006
Dec 18th, 2008
0

Re: Palindromes

First of all:
Next time post what kind of error you get and where you get it so we wouldn't have to search the entire code for the error.

And second:

This:
Java Syntax (Toggle Plain Text)
  1. public static boolean isPalindrome(s) {
  2.  
  3. }

should be:

Java Syntax (Toggle Plain Text)
  1. public static boolean isPalindrome(String s) {
  2.  
  3. }
Last edited by javaAddict; Dec 18th, 2008 at 10:02 am.
Sponsor
Featured Poster
Reputation Points: 1014
Solved Threads: 446
Nearly a Senior Poster
javaAddict is offline Offline
3,258 posts
since Dec 2007
Dec 20th, 2008
0

Re: Palindromes

And you don't have to use recursion to test whether something is a palindrome or not.
Reputation Points: 874
Solved Threads: 352
Posting Maven
BestJewSinceJC is offline Offline
2,758 posts
since Sep 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Java Beginner Need Help!
Next Thread in Java Forum Timeline: Problem with Arrays





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC