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 2 of 2

Thread: Arraylist error

  1. #1
    Member
    Join Date
    Feb 2013
    Posts
    30
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Arraylist error

    Hello All!

    I am working on a StringBuffer program and I am getting the following error message:

    Cannot find symbol - method append(java.lang.String) with this part of the code selected:

    return str1.append(str9);

    I am not sure how to fix this. Any help would be greatly appreciated! I am posting the entire code below. Thank you!

    import java.util.*;
    import java.lang.StringBuffer;
    class stringBuffProject
    {
      static String append(String str1, String str2, String str3, String str4, String str5, String str6, String str7, String str8, String str9)
      {
            return str1.append(str9);
      }
        public static void main(String[] args) 
        {
          List<String> projectStringBuffers = new ArrayList<String>();
          projectStringBuffers.add("The ");
          projectStringBuffers.add("quick ");
          projectStringBuffers.add("brown ");
          projectStringBuffers.add("fox ");
          projectStringBuffers.add("jumped ");
          projectStringBuffers.add("over ");
          projectStringBuffers.add("the ");
          projectStringBuffers.add("lazy ");
          projectStringBuffers.add("dog.");
          System.out.println(projectStringBuffers.get(0).append(projectStringBuffers.get(1)).append(projectStringBuffers.get(2)).append(projectStringBuffers.get(3)).append(projectStringBuffers.get(4)).append(projectStringBuffers.get(5)).append(projectStringBuffers.get(6)).append(projectStringBuffers.get(7)).append(projectStringBuffers.get(8)));
        }
    }


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,166
    My Mood
    Hungover
    Thanks
    141
    Thanked 597 Times in 512 Posts

    Default Re: Arraylist error

    The error message sums it up pretty well: str1 is a String, which does not have an append() method.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Replies: 7
    Last Post: September 23rd, 2013, 04:35 PM
  2. ArrayList weird display error
    By PissMaster in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 9th, 2013, 04:42 AM
  3. [SOLVED] error with equals in arraylist loop
    By Randor in forum Loops & Control Statements
    Replies: 2
    Last Post: November 27th, 2012, 09:46 AM
  4. ArrayList problem, help me to find out the error!
    By jinanzhaorenbo in forum Exceptions
    Replies: 1
    Last Post: July 30th, 2012, 10:55 PM
  5. [SOLVED] I don't know why this error using get() method from the ArrayList class
    By juanp_1982 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: February 11th, 2012, 02:11 PM

Tags for this Thread