Tagged Questions
0
votes
0answers
32 views
Differentiating String/Int User Input [closed]
I am having issues trying to type code that will make my program distinguish whether the user inputs a string value or an int value. If an int value is typed in, it will be stored into an array (named ...
-1
votes
0answers
28 views
Using for loop to get the Hamming distance between 2 strings [closed]
So i'm having some trouble with this code. i need to get the Hamming distance (the Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols ...
1
vote
1answer
64 views
High School Java Class: Pong Project External Reviewer
Panelball class:
import java.awt.*;
import java.awt.event.KeyEvent;
import javax.swing.*;
public class Panelball extends JPanel implements Runnable {
private static final long ...
1
vote
1answer
43 views
Java - Is this the correct implementation of a timer/timertask to destroy a process that overruns a defined time limit
I was wondering if this is the correct implementation of a times task to destroy a thread after it overruns a predefined time period:
it works by creating a getting the thread from ...
2
votes
1answer
124 views
JAVA, Twitter4j insert tags around entities in body
Because we're passing object to Spring Framework in which Jackson classes convert them into JSON as a reposnse we chose to Implement more simple Tweet class rather than the twitter4j provided Status ...
3
votes
2answers
92 views
String Building
Before, I had this code, sometimes it is longer:
String dbEntry = "idBldgInfo = '" + currentBldgID + "',scenario = '305',installCost='" +
installCost + "',annualSave='" + annualSave + ...
1
vote
1answer
135 views
Code review for recursion to map phone number to strings
I am trying to solve the following via recursion: In a phone we have each digit mapped to a number.
Example:
1 2(ABC) 3(DEF)
4(GHI) 5(JKL) 6(MNO)
7(PRS) 8(TUV) 9(XYZ)
* 0 ...
4
votes
1answer
198 views
efficient looping procedure to find the longest common substring java
I retrieved 200 tweets using jersey API. I want to find two tweets which have the longest common substring. This is what I have got. tweetList is an ArrayList of Tweet Objects. comapreTweets method ...
-1
votes
1answer
102 views
String.compareTo method to compare [closed]
I'm pretty new to java and don't really know about these stuff and it's my first time writing these methods! of course I have no clue how I can write them.
will you check my Method and let me know ...
4
votes
2answers
2k views
Reading a line from a text file and splitting its contents
I have this kind of file structure
MALE:FooBar:32
FEMALE:BarFoo:23
Where I would want to identify the gender and age of person, <Gender>:<Name>:<age>
try{
BufferedReader in = ...
2
votes
3answers
124 views
How to re-factor a common String comparison
Code below is scattered all over the code base :
if (StringUtils.contains(manager.getName, "custom")){
}
It just checks if an object attribute contains a predefined String and if it does, enter ...
5
votes
3answers
923 views
Approximate String Matching Interview Question
I was working on the challenge Save Humanity from Interviewstreet for a while then gave up, solved a few other challenges, and have come back to it again.
The code below generates the correct ...
5
votes
3answers
1k views
Java Date formatter
The (real life) problem
Following my question on SO, I found out that printing a Java Date() in a custom format is quite tedious:
final Date date = new Date();
final String ISO_FORMAT = ...
1
vote
1answer
130 views
Pattern Matching with Mismatch
I have been using a slightly modified Hamming Distance algorithm for approximate String Matching for patterns and wondering if there is something better out there. The t being the length of the text ...
3
votes
1answer
99 views
Is this String concatenation creating extra String?
Using the eclipse formatting on a class with some @NamedQueries created concatenations.
While I have been doing this for years without paying attention I just realised that may be it
is not a good ...