We’re rewarding the question askers & reputations are being recalculated! Read more.
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
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Favorites infavorites:mine
infavorites:1234
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
Results tagged with Search options user 7076

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.

2
votes
A few minor notes: Have the function StringReduction(str) strictly speaking, the parameter name is different: function StringReduction(s) :-) var original, key; I'd put the va …
answered Mar 8 '14 by palacsint
3
votes
It seems data envy. I'd create nameContains method in the Manager class. public boolean nameContains(final String searchText) { if (StringUtils.contains(name, searchText)) { return true; …
answered Jul 19 '12 by palacsint
0
votes
The second version looks fine. Anyway, two other quick ideas: Consider replacing only complete words (substrings which has whitespace before and after). Sort the term list by length (descending) and …
answered Mar 28 '14 by palacsint
9
votes
Actually, there is an even better structure than maps and arrays for this kind of counting: Multisets. Documentation of Google Guava mentions a very similar case: The traditional Java idiom for e …
answered Mar 12 '14 by palacsint
5
votes
You could create a few explanatory local variables: $lettersNumbersSpacesHypens = '/[^\-\sa-zA-Z0-9]+/'; $spacesAndDuplicateHyphens = '/[\-\s]+/'; Usage: $lettersNumbersSpacesHypens = '/[^\-\sa-z …
answered Mar 14 '14 by palacsint
2
votes
It looks fine. Some readability improvements: I'd rename some variables first: mismatches should be tolerance, mismatchTolerance or allowedMismatches. For me mismatches sounds like a counter but i …
answered Jun 29 '12 by palacsint
11
votes
It would be much easier with BigDecimals: String input = "00007.880000"; BigDecimal hundred = BigDecimal.valueOf(100); BigDecimal result = new BigDecimal(input).multiply(hundred).stripTrailingZeros( …
answered Mar 20 '14 by palacsint
4
votes
I agree with @Mike Nakis, plus: 1, The first loop could be changed to int holder[26] = {0}; How to initialize an array in C 2, The second loop doesn't check that bytes[i] - 97 is lower than 0 or …
answered Jan 7 '12 by palacsint
8
votes
I guess you have the naming problem because the code use the variable for multiple purposes. First, it points to the end of the pattern, then it's used for the pointer of the current character under t …
answered Feb 2 '14 by palacsint
2
votes
Using the same log message too many times could indicate that the code has some duplication. If that's the case you might want to solve this instead of curing the symptoms. For example, you could writ …
answered Feb 3 '14 by palacsint
3
votes
(Just a quick note, I don't have too much time now.) Here is another approach: int lengthOfLastWord2(const char* input) { int result = 0; while (*input != '\0') { i …
answered Mar 9 '13 by palacsint
6
votes
Ideas I had in mind were simply using char[] instead of strings being that strings are immutable and each time I concatenate the Strings, I am creating a new String object which is not efficient … at all. Yes, that will be faster. Go ahead and write it :-) Instead of Strings like strResult and strBuffer you could use StringBuilders (although using char is probably faster). StringBuilder is …
answered Mar 14 '14 by palacsint
4
votes
I'd use StringUtils.replace from Apache Commons Lang instead. It's open source, so you can check its source and its unit tests too. StringUtils.replaceEach also could be useful. By using a standar …
answered Oct 26 '12 by palacsint
4
votes
According to the Code Conventions for the Java Programming Language if statements always use braces {}. It's error-prone, so change if(chars == null) return null; to if (chars == null) …
answered Dec 27 '11 by palacsint
1
vote
I'm not completely sure about the requirements, but what about the following? public static String findWord2(final String text) { for (int i = text.length() - 1; i > 0 ; i--) { final Stri …
answered May 11 '12 by palacsint

15 30 50 per page