StringBuilder getting error using .append (Java)

2012-05-24T00:50:42

I get the following errors:

nameCombine.java:18: error: cannot find symbol
sb.append(s);"
  ^

symbol:   method append(String)
location: variable sb of type StringBuilder
nameCombine.java:19: error: cannot find symbol
        sb.append("\t");
          ^
symbol:   method append(String)
location: variable sb of type StringBuilder
StringBuilder.java:16: error: cannot find symbol
        sb.append(s);
          ^
symbol:   method append(String)
location: variable sb of type StringBuilder
StringBuilder.java:17: error: cannot find symbol
        sb.append("\t");
          ^
symbol:   method append(String)
location: variable sb of type StringBuilder

After trying to compile the following code:

import java.util.ArrayList;

public class nameCombine {
   public static void main(String[] args) {
      ArrayList<String> list = new ArrayList<String>();
      list.add("firstName");
      list.add("middleName");
      list.add("lastName");

      StringBuilder sb = new StringBuilder();

      for (String s : list) {
         sb.append(s);
         sb.append("\t");
      }

      System.out.println(sb.toString());
   }
}

I'm sorry if this is a repeat question (I'm pretty sure it is) but a quick search didn't yield anything useful, for me anyways.

What im trying to do (if you can't already tell):
Combine an arrayList (firstName, middleName, lastName) into one new string. Any suggestions as to how I can do that in Java is appreciated.

Copyright License:
Author:「user1413110」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/10724451/stringbuilder-getting-error-using-append-java

About “StringBuilder getting error using .append (Java)” questions

I get the following errors: nameCombine.java:18: error: cannot find symbol sb.append(s);" ^ symbol: method append(String) location: variable sb of type StringBuilder nameCombine.java:19: error:
I would like to add single quotes into an array of string. If I has 5 values.(1,2,3,4,5). I need like this '1','2','3','4','5' I have tried some like below but I am getting error public c
I'm studying frida. As an example, I simply created a string through the StringBuilder and append it. I hooked "append" using "frida". But it doesn't work. String val; val = &qu
I tried to append a long String (length of 3000) with java StringBuilder and found out that the appended result is not what I expected. A.append(B) should be AB A.append(LongString) becomes
reference to append is ambiguous rez.append(ROOT_FORM.containsKey(text.charAt(i)) ? ROOT_FORM.get(text.charAt(i)) : text.charAt(i)); ^ both method append(Object) in StringBuilder and method append(...
I am using StringBuilder in my project. When I appen char everything is OK, but when I try to append string "8 (" or ") " or " ", it stays empty "". Example (EDITED): int length = number.lengt...
I'm reading from an XML file and building string using StringBuilder. But sometimes my Element.Attributes are missing in which case the string is null. string key = (string)EventId.Descendants("
I have a StringBuilder object, StringBuilder result = new StringBuilder(); result.append(someChar); Now I want to append a newline character to the StringBuilder. How can I do it? result.append(...
When I am executing this program it is working absolutely fine import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexMatches { public static void ma...
I have a question. For instance: StringBuilder sb = new StringBuilder(); sb.append("Teacher,"); String s = sb.append(" Good").append("Morning!").toString(); Now in the last line I made a chain o

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.