Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 13 days ago.
Improve this question
Can anyone explain to me how to reverse a number start with zero in java. I trying to reverse a number 025 but output is only 52. But output should be 520
explanation much appreciated.
You are mixing types. "025" is not a number, it's a String. In a number you simply cannot distinguish between 25, 025, 0025, 00025, ... Implement your assignment as a String operation.
public String reverseString(String s) {
// put your code here
}
You may find very useful the Oracle tutorial on Strings here: https://docs.oracle.com/javase/tutorial/java/data/strings.html
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 months ago.
Improve this question
i have a json object and want to convert it to an int, but i get different numbers. On the first get the output is 1665750692735 (the right One), but on the getInt the output -696618113. Why?
Ok its because its an long. But how i get the long from the JSON Object?
JSON;
{"date":1665750692735,"name":"testDateTwo"}
Method:
public void add(JsonObject date) {
System.out.println((date.get("date")));
System.out.println((date.getInt("date")));
}
because the maximum value of an int is 2147483647,When long converts int, a data overflow occurs
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
This post was edited and submitted for review 1 year ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I need to print Swedish words that contain unicode using Java
how can I do it?
for example
Text with Unicode:- \u228sk\u228da
Output: åskåda
Both of the following would work:
class Main {
public static void main(String args[]) {
System.out.println("åskåda");
System.out.println("\u00e5sk\u00e5da");
}
}
Note that you need to use the hex values and must take care of specifying the encoding when reading data (from disk or network)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
Any ideas how to effeciently convert the String "TDMaturityReinvestOnNotSelected" to "TD Maturity Reinvest On Not Selected" using a java function?
Cheers
Shaun
This brilliant answer to RegEx to split camelCase or TitleCase (advanced) should work nicely.
Below is an excerpt from that answer:
final String pattern = "(?<!(^|[A-Z]))(?=[A-Z])|(?<!^)(?=[A-Z][a-z])";
for (String w : "TDMaturityReinvestOnNotSelected".split(pattern))
{
System.out.println(w);
}
And the ouput to show it running:
Edit: You'll need to reassemble the split words with spaces, but that should be trivial to work out.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to detect the file structure in a string.
e.g
if I have a string as /name/test/testme/2 I should be able to store it in a arraylist as different elements like {[name],[test],[testme],[2]}
String[] elements = "/name/test/testme/2".split("/");
More info can be found in the String.split() Javadoc
As Lukas pointed out, (please give him some upvoting) you should use the split method.
String[] elements = "/name/test/testme/2".split("/");
The regular expressions are not used to split strings in sections. Regular expressions are used for matching the target string with a specific generic format. In this case a boolean value indicating if the strings match is returned.
Hope I helped!
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
I am currently trying to make use of the java string function someString.replaceAll() to find commonly used words (and, the, by, of, etc) and replace them with " ". Based on the answers to the question at Whitespace Matching Regex - Java, I produced this function call:
data.replaceAll("(?i)\\sthe\\s", " ")
However, it isnt working and I'm really not sure why. Nothing about it looks wrong based on what I've found. Please help me!
Strings are immutable!
data = data.replaceAll("(?i)\\sthe\\s", " ");