memory « StringBuilder « Java Data Type Q&A





1. If Java Strings are immutable and StringBuilder is mutable why they wasting same ammount of memory in my code?    stackoverflow.com

I ran those code and I got some questions, this kinda got wierd. Using String:

while(true)
{
    String s = String.valueOf(System.currentTimeMillis());
    System.out.println(s);
    Thread.sleep(10);
}
Using StringBuilder:
StringBuilder s ...

2. Java: Which is the faster one and use less memory between StringBuilder.indexOf(str, index) and List.contains(o)?    stackoverflow.com

I have two file2 which contain texts. I need to have search to know which file of a given text belong. I have several ways in my mind to implement the search, ...

3. StringBuilder memory consumption    forums.oracle.com

Hi, I am using StringBuilder to build a long string and I had noticed in windows task manager that the javaw process takes a lot more memory than I had expected. For example, writting the following class: public class testStringBuilder { static String TEXT = "1000000"; private static StringBuilder str = new StringBuilder(60000000); public static void main(String[] args) { for (int ...