Tagged Questions
0
votes
0answers
11 views
setItemChecked in listview comparing to an arraylist
I create a listview from an arraylist; this arraylist contains a number of courses that a studen can take. I created a class User and I add the courses from an string[]. The problem is, I don't get ...
0
votes
1answer
18 views
Java String.replaceAll with different match & replace criteria
I have this code:
String polynomial = "2x^2-4x+16";
String input = polynomial.replaceAll("[0-9a-zA-Z][-]", "+-");
The problem is I don't want to actually replace the [0-9a-zA-Z] char.
Previously, ...
0
votes
0answers
81 views
Refactor a simple string compression (java) [on hold]
I am doing an exercise where I have to write a class to compress a string. Example: the string abcdddzee becomes abc3dz2e after compression. These are two classes (including the main). Is there a ...
1
vote
2answers
26 views
How do you display part of text field in italics in android?
I am developing an Android app which takes some data from text fields entered by the user, and outputs a single string in a new text field based on this data. Simple enough, however I need parts of ...
0
votes
5answers
41 views
remove substring in a string without using regex (cannot use replaceAll)
I need to remove some substrings in strings (in a large dataset). The substrings often contain special characters, like these: ., ^, /,... and replaceAll() would treat them as special characters for ...
-3
votes
2answers
23 views
Get String from command line → split string → if/else if statement returning else statement for no reason [duplicate]
(Sorry for the weird title, but I can't figure out what actually the problem is)
The following code should get a String from the command line first (which works), then the input is being splitted ...
-1
votes
2answers
38 views
Java convert a string to “ISO-8859-15” encoding? [on hold]
This String must be XML compatible, that is for example a < character is converted to 
1
vote
4answers
50 views
Embed variables in a string
I want to use a variable in a string but I don't know how.
Here is my code:
private AbstractAction tester = new AbstractAction("test love match") {
@Override
public void ...
1
vote
4answers
54 views
Comparing String and Integer with equals
The output of the below code is false
String str = "3456";
String str1 = "3456";
System.out.println(Integer.valueOf(str).equals(str1));
I didn't understand it. I thought it will return true. As I ...
-1
votes
2answers
42 views
Unable to switch on String type in JDK 7
I installed JDK 7 and using tomcat 7.
I'm now getting this error when using switch on a String variable,
Cannot switch on a value of type String for source level below 1.7
I also set my ...
0
votes
2answers
20 views
App ignores input after the Scanner.nextLine() method
I'm new to java and I decided to write a simple program to practice IFs. Here's what it should do:
Ask the user about the currency.
Ask the user about the amount of money he wants to transfer.
...
0
votes
3answers
34 views
Timestamp comes with .0 at the end
I'm trying to put in some time stamps in a AnnotatedTimeLine (Google Chart), and its req. to be in the Datetime format.
When I reformat (to Timestamp format) the string that I receive from the class, ...
0
votes
3answers
41 views
Regex to validate alpahanumeric or a set of special characters
I have a requirement to ensure that the string has only alphanumeric or a set of characters like + ( ) , ' . - =
I tried like
String regex = "([a-zA-Z0-9]+)|([\\'|\\()|\\+|\\,|\\-|\\.|\\="]+)";
...
1
vote
4answers
50 views
Losing precision while printing float
Please have a look at the below code:
float num = 72000000.69f;
System.out.println(String.format("%.2f", num));
Output: 72000000.00
I am loosing the precision. I have tried by converting ...
1
vote
3answers
52 views
Java: String formatting with placeholders
I am new to Java and am from Python. In Python we do string formatting like this:
>>> x = 4
>>> y = 5
>>> print("{0} + {1} = {2}".format(x, y, x + y))
4 + 5 = 9
...