0
votes
0answers
40 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 ...
2
votes
5answers
277 views

String manipulation in Java

Here is the question followed by my program which works good Given a string, return a version without the first 2 chars. Except keep the first char if it is 'a' and keep the second char if it is 'b'. ...
-1
votes
0answers
32 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
69 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 ...
2
votes
1answer
54 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
130 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
138 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
210 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
103 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 ...
5
votes
3answers
159 views

Java string replace

I am new to Java and I am trying to learn about optimizing code to make it production ready. I have the following code below. I would like to know how I could optimize it. I thought by using a small ...
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
944 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 2
15 30 50 per page