Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
while (in > h-1 && n[in-h] >= wrapperTemp)
I am writing a program but it deals with objects, so using the >,>=, symbols aren't going to help me in this case.
in, h, and wrapperTemp are all variables.
- this is written in the java language
I think you just want this
while (in.compareTo(h-1) > 0 && n[in-h].compareTo(wrapperTemp) >= 0)
Try,
while (in > h-1 && (n[in-h].compareTo(wrapperTemp) >=0))
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 days ago.
Improve this question
So my program is working , the program is to check if a number is Automorphic,Trimorphic,Tri-Automorphic or its not a type of automorphic.
But I have a doubt , that is , what does this do:
for (I = a ; I> 0 ; I = I / 10 )
{
C++;
}
I tried to remove C++ but that didn't work.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have part of the code:
public void CollectorOrPocrushka(double output) {
if (output <= 0.4999999999999999999999)
System.out.println("покришка");
if (output > 0.5 && output <= 1.0)
System.out.println("колектор");
}
Can I write float number 0.4999999999999999999999 shorter?
Something like that:
0.49F
0.49e^10
If your question is about to simplify the first if condition and your goal is to check if the output is less than or equal 0.4999999999999999999999, you can easily write
if(output < 0.5)
System.out.println("покришка");
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am trying to make a program where I can't find a solution for this:
I want to check if position_x is 0 or 20 or 40 or 60 or 80 or 100 or 120... until 1280 (always plus 20).
I hope you can help me further,
Thanks!
You can try using the modulus here, e.g.
if (position_x % 20 == 0 && position_x >=0 && position_x <= 1280) {
System.out.println("position_x is a multiple of 20 and within range.");
}
else {
System.out.println("position_x is out of range or not a multiple of 20.");
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a user input into a input box and want to find whether user entered the text format like 'XXX-XXXXXX'
How do I do this in java?
You could use split.
String str = "XXX-XXXXXX";
String[] words = str.split("-");
if(words[0].toCharArray().length == 3 && words[1].toCharArray().length == 6 && words.length == 2)
{
System.out.println("Correct");
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Please tell me any method or logic to precede characters alphabetically (i.e., get the alphabetic predecessor of a character) eg. predecessor of a is b. I have searched the net but found nothing. Any help would be appreciated.
If you are asking how to get 'a' from 'b', it's quite simple :
char x = 'b';
x--;
System.out.println(x); // prints a