import java.rmi.Naming; import java.rmi.Remote; import java.rmi.RemoteException; import…
- User
import java.rmi.Naming; import java.rmi.Remote; import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; import java.util.*; import java.util.List; import java.util.Map; public class JavaApplication60 {
public class EncyclopediaServiceImpl extends UnicastRemoteObject implements EncyclopediaService { private List encyclopedia;
codepublic EncyclopediaServiceImpl() throws RemoteException { super(); encyclopedia = generateRandomData(300); } private List<String> generateRandomData(int numWords) { List<String> words = new ArrayList<>(); Random random = new Random(); for (int i = 0; i < numWords; i++) { int wordLength = random.nextInt(10) + 1; // Random word length between 1 and 10 characters StringBuilder word = new StringBuilder(); for (int j = 0; j < wordLength; j++) { char c = (char) (random.nextInt(26) + 'a'); // Random lowercase letter word.append(c); } words.add(word.toString()); } return words; } @Override public int count() { int letterCount = 0; for (String word : encyclopedia) { letterCount += word.length(); } return letterCount; } @Override public List<String> repeatedWords() { Set<String> uniqueWords = new HashSet<>(); List<String> repeatedWords = new ArrayList<>(); for (String word : encyclopedia) { if (!uniqueWords.add(word)) { repeatedWords.add(word); } } return repeatedWords; } @Override public String longest() { String longestWord = ""; for (String word : encyclopedia) { if (word.length() > longestWord.length()) { longestWord = word; } } return longestWord; } @Override public String shortest() { String shortestWord = ""; if (!encyclopedia.isEmpty()) { shortestWord = encyclopedia.get(0); for (String word : encyclopedia) { if (word.length() < shortestWord.length()) { shortestWord = word; } } } return shortestWord; } @Override public Map<String, Integer> repeat() { Map<String, Integer> wordCount = new HashMap<>(); for (String word : encyclopedia) { wordCount.put(word, wordCount.getOrDefault(word, 0) + 1); } return wordCount; } @Override public List<String> getData() { return null; } - Assistant
To solve this error, you need to create an instance of the outer class
JavaApplication60before creating an instance of the inner classEncyclopediaServiceImpl. Here's the updatedmainmethod:java