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
I have a list that I made with a type I created of . I want to sort it in lexicographical order. I have seen the compareTo in Java, am I supposed to use this? I'm not sure how to put it into the lexographical format from a list? Can anyone show me an example? I have seen many examples, but I am not sure how to do it from a list.
Just use implement the Comparable<Type> in your own Type class and implement the compareTo method to match the lexicographical order. Than just call Collections.sort(yourlistOfTypes).
Related
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
I create a Hashmap xxx
store all Thread inside Hasmap
when Thread finish , will remove it
is it a good practise?
Here is my code : https://gist.github.com/extralam/756484718c9e0cd57ddb
The right way, since Java5, is the use of the ThreadPoolExecutor.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I'm trying to implement an stack using a linked list in Java, But I'm not sure which methods I have to implement(stack is a simple example here), How can I somehow get the methods and then extend my linked list class to implement my own class of stack
I know that somehow I have to use some kind of interface but it would be a great help if someone could guide me here.
A stack at its simplest just has Push() and Pop(). They map directly to the LinkedList methods push and pop already present!
So in order to implement a stack on top of a linked list you need to do....nothing :)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
Is there a similar syntax to Java's .hasNext() method in Ruby? I've been trying to get inputs in one line and then making it as integers and getting the absolute value.
It sounds like you want to see if there are more elements left in an iteration. Ruby's equivalent to that is peek:
From the docs:
Returns the next object in the enumerator, but doesn’t move the internal position forward. If the position is already at the end, StopIteration is raised.
But, in Ruby we usually rely on each or map to walk an iterable collection. There's no "figuring out" whether there's another element remaining, because Ruby does that for us.
ansh0l is right, gets is the most likely equivalent to hasNext() assuming that you're reading from the keyboard or any other I/O stream.
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 have a list of names (surnames) and a simple search mechanism. I would like to have words with minor changes (typos) shown in search results.
Example search text: braniecka
Example result: Branicka, Kraniecka, Braniecki
Any help appreciated.
You can implement the Levenshtein distance. It is a widely used algorithm.
You could also consider upgrading your solution to Lucene, especially if you are doing any production work. Lucene handles your requirement in an extremely performant way (no brute-force exhaustive search).
Try using simmetrics.
Is a library for measuring string similarity and implements many algorithms.
http://sourceforge.net/projects/simmetrics/
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 have below string which I get from an xml file.
<product>
<aa>1367</aa>
<ac>133787</ac>
<db>13345</db>
<ce>133</ce>
<er>135</er>
<et>130</et>
<ef>14</ef>
</product>
How do I convert it to an two dimension array like
product[][]={{"aa", "1367"},{"ac","133787"}, {"db","13345"}....}
I only want to use string function and loop.
I think the best way is to use an available XML parser.
In this thread: Best XML parser for Java you'll probably find which one is the best to use