Linked Questions
14 questions linked to/from StringBuilder/StringBuffer vs. "+" Operator
3
votes
4
answers
4k
views
When is the + operator faster than a StringBuilder? [duplicate]
In the past, I have been lead to believe that you should use StringBuilder and append(String) when building a string with variables, as opposed to string += split[i]. In what cases is this accurate? I ...
1127
votes
20
answers
519k
views
StringBuilder vs String concatenation in toString() in Java
Given the 2 toString() implementations below, which one is preferred:
public String toString(){
return "{a:"+ a + ", b:" + b + ", c: " + c +"}";
}
or
public String toString(){
StringBuilder ...
402
votes
9
answers
327k
views
When to use StringBuilder in Java [duplicate]
It is supposed to be generally preferable to use a StringBuilder for string concatenation in Java. Is this always the case?
What I mean is this: Is the overhead of creating a StringBuilder object, ...
85
votes
12
answers
50k
views
Print the contents of a Bundle to Logcat?
Is there an easy way to print the contents of a Bundle to Logcat if you can't remember the names of all the keys (even being able to print just the key names would be cool)?
134
votes
7
answers
35k
views
How does the String class override the + operator?
Why in Java you're able to add Strings with the + operator, when String is a class? In theString.java code I did not find any implementation for this operator. Does this concept violate object ...
3
votes
4
answers
869
views
StringBuffer append() or String +? [duplicate]
Possible Duplicate:
java String concatenation
StringBuilder vs String concatenation in toString() in Java
I ve read some articles about append() is much faster than +, but what is the reason ,...
-1
votes
3
answers
6k
views
String concat not working in java
I have the following code:
private String foo;
public void setFoo(String bar)
{
foo = bar + "bin/";
}
I expect this code to concat bar and "bin/" using the overloaded '+' operator. And when I do ...
2
votes
2
answers
937
views
The String class and Java's dependency on it
So everyone knows that the shortest Java program that you can write is:
public class Program{
public static void main(String []args){
}
}
One would suspect that this shortest program would ...
1
vote
3
answers
573
views
Coming across NoClassDefFoundError in java
I come across an error while running this in Java:
// Test.java
public class Test {
public static void main(String [] args) throws IOException {
String a = "123";
a = a + "456";
...
1
vote
4
answers
175
views
Can we use the + sign to add a string literal in a StringBuffer?
StringBuffer sb = new StringBuffer();
sb.append("New "+"Delhi");
and other is:
sb.append("New ").append("Delhi");
both will print "New Delhi".
Which one is better and why?
Because some times to ...
0
votes
2
answers
202
views
Android - how to link to dynamically constructed resource identifiers in a performant way?
I have to open a webview which loads a dynamic url based on certain parameters, I have to create the url based on different strings.
What I'd like to do is the following:
String webPage = "www....
0
votes
1
answer
221
views
Giraph application get stuck, on superstep 4, all workers active but without progress
I'm doing BFS search through the Wikipedia (spanish edition) site. I converted the dump (https://dumps.wikimedia.org/eswiki/20160601) into a file that could be read with Giraph.
The BFS is searching ...
-1
votes
2
answers
97
views
NullPointerException , program doesn't compile
I've got a question to my program:
public class Muster2 {
int[] farben;
constructs an array with 4 integers
public Muster2(int f0, int f1, int f2, int f3) {
int[] farben = new int[4];
farben[0] = ...
0
votes
1
answer
94
views
Read and analyze text files containing both numbers and letters on the same line
I'm given a task to read data from a text file and save it to a Set. Text file represents an imaginary bill containing certain item description and it's price, quantity and total sum. I only need item'...