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)
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.
Improve this question
If I were to run my code using java example hello 3 the output would be hello 3
However, if I want to run java example hello world 3 the output would be hello world not hello world 3
How would I fix this?
public static void main(String[] args){
String t = args[1];
int s = Integer.parseInt(args[0]);
System.out.println(t)
System.out.println(s)
Taken from this answer: https://stackoverflow.com/a/17619865/6590339
You can use quotes when you want an argument to have a space in it:
$java example "hello 3"
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 6 years ago.
Improve this question
How to parse below result xml(?) using SimpleXML?
<boolean xmlns="http://schemas.microsoft.com/2003/10/Serialization/">true</boolean>
I've solved parsing like this:
#Root(name="boolean")
public class LogonResult {
#Text
boolean _boolean;
}
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
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 8 years ago.
Improve this question
I'm trying to power something to negative number but it always gives me NaN or Infinity.
How to make eg. 1.25^(-5) ?
The following code:
public class HelloWorld{
public static void main(String []args){
System.out.println(Math.pow(1.25, -5));
}
}
prints:
0.32768
Here is a working code snippet
You can use the Math.pow() method
Math.pow(1.25, -5)