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
I need to define specific numbers out of an array of 52 numbers so I can assign them an image (yes I am creating an applet). I don't think that code is necessary for any of you to answer this question. Any help would be fantastic.
I'm not sure I understand what you're asking. You can set an item in an array this way:
myArray[4] = 52;
That would set array index #4 (remember it's zero based so it's actually the 5th item) to the value of 52. Is that what you're looking for?
Related
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 17 days ago.
Improve this question
I am trying to produce all permutations of an array of size N (i.e. N = 9) with possible elements Z (i.e. Z = [0,1,2,3,4])
Duplicates are allowed, but there needs to be at least one. I am able to write the algorithm to go through all possibilities but the minimum of at least one of each of Z is the part I'm having trouble with.
Looking to do this algorithm in java. Can someone help?
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 last month.
Improve this question
I have a list of strings in random format:
AppName-ver-1.1.0-data.exe
AppName-ver-1.1.1-secondData.exe
AppName-ver-1.2.0-data.exe
AppName-ver-1.2.1-data.exe
AppName-ver-1.2.3-data.exe
AnotherAppName-ver-1.0.0-data.exe
AnotherAppName-ver-1.0.0-secondData.exe
What would be an efficient way in java to find the closest value to string:
AppName-ver-1.2.4-data.exe
UPD: closest - by the naming not length so AppName-ver-1.2.3-data.exe is the expected result
To emphasize what commenters already pointed out:
If you define 'closest' to be the string length, then
AppName-ver-1.2.4-data.exe has the value 26, and
AppName-ver-1.1.0-data.exe
AppName-ver-1.2.0-data.exe
AppName-ver-1.2.1-data.exe
AppName-ver-1.2.3-data.exe
all resemble 26 as well so they are a direct match.
You could also define 'closest' to have the least Hamming Distance. This will give completely different results and AppName-ver-1.2.0-data.exe might win as it is just one bit off.
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 3 years ago.
Improve this question
I tried it with Sieve Of Eratosthenes, but I quickly run into the problem that my boolean array can't go past Integer.MAX
How should I approach this problem?
Arrays
Use 2 or more dimensional maps. So converting long to two integers (for accessing the arrays) will be like this:
array[N / Integer.MAX_VALUE][N % Integer.MAX_VALUE] where N is long and array is the boolean array.
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 4 years ago.
Improve this question
I have a list of users and they have status as attribute and I want
the users who have status 'disable' be at the end of the list. There are 4 types of status: 'disable', 'connect', 'notConnect', 'deleted'.
You can sort the list using a Comparator that evaluates "disable" as larger than any other status.
users.sort(Comparator.comparingInt(user -> "disable".equals(user.status) ? 1 : 0));
You can extend this solution by adding integer rankings for the other statuses as well.
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 7 years ago.
Improve this question
I am currently writing a game in Java, where words in a string will have to be all changed to equal 5 characters a word.
eg. I am writing in Java
Iamwr iting inJav a
I wonder if anyone knows how I would do this?
First remove spaces between words.
Then split that resulting String to length with 5.
Add a space after every 5 character.