stringbuffer Questions
9
I have follows below XML feed:
<Description>
<p>Touch, tap, flip, slide! You don&#39;t just read Books, you experience it.</p>
</Description>
Here I have to display ...
Wreathe asked 4/3, 2013 at 7:16
11
Can anyone help me and tell how to convert a char array to a list and vice versa.
I am trying to write a program in which users enters a string (e.g "Mike is good") and in the output, each whitespa...
Peritoneum asked 23/3, 2013 at 18:45
33
Solved
What is the main difference between StringBuffer and StringBuilder?
Is there any performance issues when deciding on any one of these?
Rowney asked 10/12, 2008 at 4:34
3
Solved
I was under the impression that StringBuffer is the fastest way to concatenate strings, but I saw this Stack Overflow post saying that concat() is the fastest method. I tried the 2 given examples i...
Overindulge asked 21/3, 2016 at 0:26
4
Solved
deleteCharAt or setLength, which way is better to remove last char from a StringBuilder/StringBuffer
In many cases, we need to delete the last char of a StringBuilder/StringBuffer. For example, given a int[]{1,2,3}, to implement a String toString(int[] a) method, contacting each elements with a co...
Quadriplegic asked 8/2, 2014 at 11:41
6
I want to know how to add or append a new element to the end of an array. Is any simple way to add the element at the end? I know how to use a StringBuffer but I don't know how to use it to add an ...
Antheridium asked 16/2, 2015 at 20:8
14
Solved
When I run this code:
StringBuffer name = new StringBuffer("stackoverflow.com");
System.out.println("Length: " + name.length() + ", capacity: " + name.capacity());
it gives output:
Length: 17...
Awhile asked 4/11, 2011 at 15:19
27
Solved
Is there a way in Java to create a string with a specified number of a specified character? In my case, I would need to create a string with ten spaces. My current code is:
final StringBuffer outpu...
Malignancy asked 10/5, 2010 at 17:21
8
Solved
I have the following code where I am trying to put the StringBuffer objects as keys in a TreeSet. The reason I do this is to see if I can put mutable objects as keys. I do not get any compile error...
Characharabanc asked 22/8, 2013 at 19:33
5
Solved
I have read some articles about the pros and cons of String and StringBuilder in the Java Programming language. In one of the articles, the author mentioned that:
StringBuilder is not Thread-saf...
Legato asked 11/11, 2014 at 7:59
2
Solved
example code:
StringBuffer sb = new StringBuffer("hi");
sb = null;
Question:
will the literal string "hi" somehow stay in memory, even after the StringBuffer has been garbage collected? O...
Hailstorm asked 20/12, 2018 at 21:28
10
Solved
As per my knowledge,
a mutable string can be changed, and
an immutable string cannot be changed.
Here I want to change the value of String like this,
String str="Good";
str=str+" Morning";
and...
Diminished asked 5/8, 2014 at 12:15
5
Solved
I have searched about this, but I couldn't find why StringBuilder's ensureCapacity() method won't lengthen the old capacity by just doubling but also adding two.
So, when default capacity of 16 is...
Bangweulu asked 14/7, 2017 at 4:17
2
Solved
In JDK 8, StringBuffer class has a toStringCache, while StringBuilder doesn't.
/**
* A cache of the last value returned by toString. Cleared
* whenever the StringBuffer is modified.
*/
private ...
Karylkarylin asked 19/9, 2017 at 7:33
2
Solved
I was trying to figure out when to use or why capacity() method is different from length() method of StringBuilder or StringBuffer classes.
I have searched on Stack Overflow and managed to come up...
Notation asked 6/9, 2017 at 9:24
8
Solved
Suppose our application have only one thread. and we are using StringBuffer then what is the problem?
I mean if StringBuffer can handle multiple threads through synchronization, what is the proble...
Rubstone asked 30/5, 2011 at 9:2
2
Solved
I have a string with markdown syntax in it, and I want to be able to find markdown syntax for headings, i.e h1 = #, h2 = ## etc etc.
I know that whenever I find a heading, it is at the start of th...
Smarmy asked 22/5, 2017 at 8:56
2
Solved
I have a StringBuffer initialized outside for loop and inside for loop I am concatenating some strings.
I am getting the warning
'StringBuffer stringBuffer' may be declared as 'StringBuilder'...
Reason asked 30/3, 2017 at 3:36
4
Solved
I know that Javac compiler is able to transform String concatenation + using StringBuilder/StringBuffer, and I'm curious to know starting from which version this change was introduced?
I'm using t...
Alessandraalessandria asked 27/2, 2017 at 14:15
1
I have the following piece of code in Java.
String foo = " ";
Method 1:
StringBuffer buf = new StringBuffer();
buf.append("Hello");
buf.append(foo);
buf.append("World");
Method 2:
StringB...
Dey asked 7/6, 2016 at 7:14
15
Solved
What is the difference between String and StringBuffer in Java?
Is there a maximum size for String?
They asked 13/3, 2010 at 17:25
6
The title says it all. Is there any way to convert from StringBuilder to byte[] without using a String in the middle?
The problem is that I'm managing REALLY large strings (millions of chars), and...
Astraphobia asked 19/10, 2013 at 22:50
8
Solved
How can we re assign the value of a StringBuffer or StringBuilder Variable?
StringBuffer sb=new StringBuffer("teststr");
Now i have to change the value of sb to "testString" without emptying the...
Corticosteroid asked 7/4, 2010 at 11:10
10
I'm pasting this text from an ebook I have. It says the complexity if O(n2) and also gives an explanation for it, but I fail to see how.
Question: What is the running time of this code?
public St...
Wheeze asked 23/8, 2011 at 4:1
5
Solved
I a writing a webapp in Java 1.6 and running it in tomcat. While I am not doing any explicit threading, I wonder about what is going on behind the scenes with Spring and Tomcat. Would I run into an...
Osbourn asked 23/8, 2012 at 20:5
1 Next >
© 2022 - 2024 — McMap. All rights reserved.