Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Program compiles with a cannot find symbol error- what is that?

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Location
    United States
    Posts
    16
    My Mood
    Lurking
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Program compiles with a cannot find symbol error- what is that?

    Here is the scope of my program:
    Implement a program that reads a Twitter update (a “tweet”) and prompts the user to provide translations for texting abbreviations within the update. When the user presses the ENTER key by itself to indicate no more translations, the program should display the Twitter update with the translations substituted for the abbreviations. In the displayed Twitter update, for each abbreviation, the abbreviation’s first translation should be followed by the abbreviation within parentheses. In the sample session, notice the “(ru)” following the first “are you” substitution.

    The fun (and curse) of Twitter is that messages are limited to 140 characters each. If the user enters a Twitter update longer than 140 characters, your program should process the update up to and including the 140th character and skip any additional characters.

    This is the program that I've written, but I keep getting an error
    /************************************************
    * TweetDecoder.java
    * Jennifer Stanek
    *
    * This program decodes tweets up to 140 characters
    * based upon user-based corrections
    *************************************************/
     
    import java.util.Scanner;
     
    public class TweetDecoder
    {
      public static void main (String[] args)
      {
    	Scanner stdIn = new Scanner(System.in);
        String tweet; // User entered tweet
        String abbreviation = "C"; // abbreviation in tweet that is to be replaced, initialized to begin loop
        String replacement; // Replaement text for abbreviation
     
        System.out.println("Enter a tweet (anything over 140 characters will be cut off):");
        tweet = stdIn.nextLine();
        if (tweet.length()>140)
        {
        tweet = tweet.substring(0,140); // Takes the tweet down to 140 characters
        }
        while(!abbreviation.equals(""))   // While to continue as long as the input is not empty set
          {
            System.out.println("\nEnter abbreviation that is to be replaced (or press ENTER to quit): ");
            abbreviation = stdIn.nextLine();  //User entered abbreviation that is to be replaced
            System.out.println("Enter replacement text: ");
            replacement = stdIn.nextLine ();  //User entered replacement for abbreviation
            replacement = replacement + "(" + abbreviation + ")";  // change replacement to replacement value and original value in parentheses
            tweet = (tweet.replaceALL(abbreviation, replacement));  // New tweet with specificed charaters replaced
            }// End While that is chekcing for empty set
          System.out.println("/nHere is your translated tweet:/n" + tweet);  // Prints out new tweet
      } // End Main
    } // End class TweetDecoder

    C:\Users\Jennifer\Documents\school\TweetDecoder.java:33: error: cannot find symbol
            tweet = (tweet.replaceALL(abbreviation, replacement));  // New tweet with specificed charaters replaced
                          ^
      symbol:   method replaceALL(String,String)
      location: variable tweet of type String
    1 error
     
    Tool completed with exit code 1

    I can not figure out what I'm doing wrong. To be fair, the book's examples of replaceALL were horrible, but I thought I was using it correctly. Any help would be appreciated.


  2. #2
    Member
    Join Date
    May 2011
    Location
    west palm beach, FL
    Posts
    189
    My Mood
    Tired
    Thanks
    41
    Thanked 11 Times in 10 Posts

    Default Re: Program compiles with a cannot find symbol error- what is that?

    in your replaceAll you have it as replaceALL when it should be replaceAll with lowercase L's

  3. The Following User Says Thank You to derekxec For This Useful Post:

    kissyfurs (July 10th, 2013)

  4. #3
    Junior Member
    Join Date
    Jul 2013
    Location
    United States
    Posts
    16
    My Mood
    Lurking
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Program compiles with a cannot find symbol error- what is that?

    I can't believe that was all I did wrong. Thanks for your help in pointing that out- I made a few other small changes and it works perfectly!

  5. #4
    Member
    Join Date
    May 2011
    Location
    west palm beach, FL
    Posts
    189
    My Mood
    Tired
    Thanks
    41
    Thanked 11 Times in 10 Posts

    Default Re: Program compiles with a cannot find symbol error- what is that?

    great

Similar Threads

  1. [SOLVED] cannot find symbol error
    By Topflyt in forum What's Wrong With My Code?
    Replies: 9
    Last Post: November 5th, 2011, 08:57 AM
  2. Cannot find symbol ERROR
    By yacek in forum What's Wrong With My Code?
    Replies: 8
    Last Post: October 21st, 2011, 11:39 PM
  3. error :cannot find symbol
    By iswan in forum AWT / Java Swing
    Replies: 1
    Last Post: October 1st, 2011, 08:26 AM
  4. Cannot find symbol error
    By AnuR in forum What's Wrong With My Code?
    Replies: 9
    Last Post: February 23rd, 2011, 02:50 PM
  5. cannot find symbol Error
    By bananasplitkids in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 9th, 2010, 02:36 AM