|
Simple question I think. I have a very long string, that I want to take all n-length substrings out of and place into an array. For example if n is 5 and the sentence is "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt whatever", I would want string one to be "Lorem ipsum dolor sit amet," , string two to be "ipsum dolor sit amet, consectetur", string three to be "dolor sit amet, consectetur adipisicing", and so on. What would be the best way to go about this? I am having a hard time getting anything to work really.
|
# ¿ Apr 17, 2008 05:34 |
|
|
# ¿ Apr 27, 2024 08:19 |
|
Haha it might be homework. I really just needed a point in the right direction like you gave, just some methods to look at. I've considered putting the words in some sort of array, I'm just worried about the efficiency of putting them there in the first place. I'll definitely check those methods out though, thanks.
|
# ¿ Apr 17, 2008 14:46 |
|
I have a question about the HashMap class. I have populated a HashMap with a simple object I have created, basically consisting of two strings. One of these strings holds a segment of text from a file, the other holds the file name. What I want to do is to use the HashMap.contains method to determine if a particular string matches any of the text segments, and then use whatever get method is in the class to determine the file name. I figured that overriding the hashcode method would do the trick; I defined the hashcode method of the class to return the hashcode value of the string that we will be searching for. Apparently, this doesn't quite do the job. I am fairly new to hash tables, so if anyone could give me a few tips it would be very appreciated.
|
# ¿ Apr 22, 2008 02:57 |
|
I had a nice long post typed up and lost it due to the forum maintenance. Basically I asked if this code:code:
edit: This works perfectly, even better than I had hoped it would. Thanks for the help. clayburn fucked around with this message at 04:51 on Apr 22, 2008 |
# ¿ Apr 22, 2008 04:25 |
|
It looks like I have another problem with my HashMap involving collisions. Looking at my data set, I know for a fact that collisions are happening, and this is causing problems for me. Every time that I search for a value at a specific key, I only get one of the values, where sometimes I may want the other value. For example, if "foo" and "bar" are stored at the same key, I will only ever get "foo" even though sometimes I may want to find any string that is not "foo." Is there any way to go about this? I have read the API entry for HashMaps over and over and cannot seem to find a solution to this.
|
# ¿ Apr 23, 2008 16:48 |
|
Yes, and I'm starting to get the impression that it was a really bad idea. I thought that it would simply handle that as a collision and store the object somewhere else that would still be accessible.
|
# ¿ Apr 23, 2008 17:15 |
|
I've never really used done any sort of GUI stuff before, but I am currently trying to implement some Swing stuff using NetBeans GUI Builder. I have two problems that I can't seem to figure out. Basically I want to browse file much like the Windows Explorer does. I want a file tree on the left column with the detailed list view using the rest of the window. I can not figure out how to get the JTree to point to the file structure or how to make sortable columns in a JList. Is there some easy way to do either of these things or am I going to have to hack something together?
|
# ¿ Jun 27, 2008 00:01 |
|
Anyone know how to restore the build.xml file that NetBeans creates? I have a project and somehow mine got messed up and now it won't compile.
|
# ¿ Jul 18, 2008 00:06 |
|
|
# ¿ Apr 27, 2024 08:19 |
|
Well I had it working fine, then I started working on another project and since then the other one has been messed up. Now that you say that though I think I may know more what the problem is, so thanks for pointing that out. Is there a way to fix the nbprojects files? I still have all of the source code but those have somehow gotten messed up. clayburn fucked around with this message at 00:32 on Jul 18, 2008 |
# ¿ Jul 18, 2008 00:29 |