954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Java Help

im trying to take an inputed file and use a linked list to read it and display the most frequently used word. Anybody know how to do it?

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.*;
public class mostFrequentWord 
{
	LinkedList<Word> list = new LinkedList<Word>();
	public void Read()
	throws FileNotFoundException
	{
		Scanner input = new Scanner(System.in);
		FileReader reader = new FileReader("test.txt");
		Scanner in = new Scanner(reader);
		in.useDelimiter(" [ ^ a - zA - Z ] + ");
		while (in.hasNext())
		{
			String s = in.next().toLowerCase();
			System.out.println(s);
		}
		
		
		
	
		
	}
}
import java.util.LinkedList;

public class Word 
{
	private String toWord;
	private int Count;
	
	public void assign(int count, String word)
	{
		toWord = word;
		Count = count;
	}
	public void isEqual()
	{
		LinkedList<Word> list = new LinkedList<Word>();
		
		 String x = "?";
		 String x2 = "?";
		 if (x.equals(x2))
		 {
			 System.out.println("?");
		 }
		 
	}
	
	
	

}
import java.io.FileNotFoundException;

public class testmostFrequentWord 
{
	public static void main(String[] args) 
	throws FileNotFoundException 
	{
		mostFrequentWord  m = new mostFrequentWord();
		Word w = new Word();
		m.Read();
		w.isEqual();

	}

}

been at it all week, thats all i got. please help :)

help_please
Newbie Poster
16 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

http://www.daniweb.com/forums/thread274782.html

What is it about the help I gave you in that thread that is insufficient? I gave you code examples, detailed explanations, etc. It seems like you want someone to do your project for you. To do your project, you need to know the following:

Classes, methods, a very basic understanding of Java Generics, how to use Iterators, how to use the equals() method (you don't need to know how to implement it though, but it might help if you read up on it), a basic understanding of how to use the Scanner class or how to otherwise read in from a file. I suggest you get started on reading the Sun Microsystems (now owned by Oracle) Java tutorials.

Oh, and as your incorrectly defined LinkedList (from your previous thread) showed me, you also need to read about variable scope. You can't declare a variable inside a for loop and expect it to exist once the loop finishes. What exactly have you been learning in class all this time?

BestJewSinceJC
Posting Maven
2,772 posts since Sep 2008
Reputation Points: 874
Solved Threads: 354
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You