I need to replace a random word that I pick in the MovieList into underscore "___", I think about create a new method to handle it, the new method should be under the class guessMovies, and then I will call method under "object r" to replace every single word into underscore, but Java said it cannot find symbol ( it doesn't know what "r" is ). Please help.
Thank you
public class guessMovies {
public static void main(String[] args) throws IOException {
String MovieList;
ArrayList<String> MovieNames = new ArrayList<>();
try (BufferedReader br = new BufferedReader(new FileReader("MovieList.txt"))) {
while ((MovieList = br.readLine()) != null) {
MovieNames.add(MovieList);
}
for(String movieName: MovieNames){
System.out.println(movieName);
}
Random r = new Random();
System.out.println(MovieNames.get(r.nextInt(MovieNames.size())));
}
catch(FileNotFoundException exception) {
System.out.println("I cannot find your file");
}
//pick random movie
}
}
Aucun commentaire:
Enregistrer un commentaire