Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
A string is a sequence of characters. It is commonly used to represent text or a sequence of bytes. Use this tag along with the appropriate programming language being used.
3
votes
Read and convert binary files to ASCII text
You absolutely must close that Scanner.
This snippet
The scanner loop
while (sc.hasNextLine()) {
String line = sc.nextLine();
lastString = lastString + line;
}
creates a new String Objec …
10
votes
String manipulation in Java
Just recoded it, doing simply what your explanation said
Except keep the first char if it is 'a' and keep the second char if
it is 'b'.
Since a possible deletion of a character will affect in …
12
votes
Accepted
Collection of exact string matching algorithms in Java
The Matcher implementations
You group all these matchers in a StringMatchers class. Other than grouping the matchers together, this class adds no real benefit.
All macher's match() methods are static …
3
votes
Add a newline to a String if not empty in Java
I fear there isn't much to improve. You could avoid the concatenation if the String is empty :
myString = myString.isEmpty() ? myString : myString + '\n';
5
votes
Check for balanced parentheses
I've only one addition to the other answers
For the stack you use java.util.Stack, this seems like an obvious choice, yet it is a remnant from pre-collection times, and is a subclass of java.util.Vec …