yes, to see if it exists. if it doesn't, return null.
Type: Posts; User: waltershc
yes, to see if it exists. if it doesn't, return null.
I need the get method to receive a string value, check if it exists in the tree, and return either the object/key that the string corresponds to or a null value if it does not exist. I know I need...
This is one of three trees I am using to parse text and print out every unique word, the line numbers it appears on, and the number of times it appears. I have already used a hash and tree map and...
There is currently no point in my code that saves an item for checking. How would I save the value itr.next() prints? I cannot make some integer variable and just assign it to equal itr.next() as...
I have tried various forms of that
//local occurance variable
int occurance = 1;
String check = "";
//System.out.println("pE entry=" + entry.getValue().toString());
//print the...
Unfortunately not. It is still printing out the second 3 for mouse.
Output:
wordMap=[cat=[2], mouse=[3, 3], phone=[4, 5], string=[1]]
pE entry=[2]
ID: [cat] Lines: 2 Occurance: [1]
pE entry=[3, 3]
ID: [mouse] Lines: 3, 3 Occurance: [2]
pE entry=[4, 5]...
So you are saying what needs to be inserted into the linked list needs to be a string including the line number instead of an integer? ...Or are we just talking about output for debugging purposes?
What is your suggestion? I must be missing the point. I do not see how my printout is different from yours except for the concatenation of "wordMap=" and "pE entry=".
wordmap is line 2. the values for each entry are above their respective entries.
Running.
[cat=[2], mouse=[3, 3], phone=[4, 5], string=[1]]
[2]
ID: cat Lines: 2 Occurance: 1
[3, 3]
ID:...
I want to compare the objects(ints aka line numbers) in the linked list that are stored in the value location on the TreeMap.
The linkedlist's line values.
public static void printEntry(Map.Entry entry){
//local occurance variable
int occurance = 1;
System.out.println(entry.getValue().toString());
//print the word and the line numbers...
Well one problem I can see is that you are scanning for the name and score after the if-statements that test them. The if-statements would have already ran when the variables are filled with the...
//Name: Hal Walters
//Class: SCSC 321
//Date: 3/10/2013
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.*;
public class driver1 {
//Name: Hal Walters
//Class: SCSC 321
//Date: 3/10/2013
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.*;
public class driver1 {
Forgive my ignorance, but where? There is a hasNext() call on line 49 when it runs through the iterator to call the printEntry method.
So get rid of the elseif statement and put something in around the while loop at the bottom of the main class?
Running.
Exception in thread "main" java.util.NoSuchElementException
at java.util.LinkedList$ListItr.next(Unknown Source)
at driver1.printEntry(driver1.java:67)
at...
http://i110.photobucket.com/albums/n92/dcmystery21/Untitled-1.png
Thanks for the help so far. Let me know if you cannot read the text.
//Read the words and add them to the wordMap
for (int lineNum = 1; (oneLine = inFile.readLine()) != null; lineNum++){
StringTokenizer st = new StringTokenizer(oneLine);
while...
Not for a single identifier. In other words, any given line number should not appear more than once on a line in the console.
--- Update ---
I played around with that a little bit but...
if (itr.toString() != itr.next().toString()){
System.out.print(", " + itr.next());
occurance++;
}
else{
return;
}
well, i know this much already doesn't work. It should...
I updated the first post.
Edit- Also went back and messed around with my code more and got it to a point where I feel it is even closer. I also added some code for formatting and counting word...
I have made a good bit of progress with my code and am now stuck on something I believe to be quite simple. I have it printing out the line numbers that the word occurs on in the supplied text file...