Putting void in front says start of illegal expression which I also don't fully understand
package com.codegym.task.task14.task1407;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/*
Player and Dancer
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
Person person = null;
String key;
while (!(key = reader.readLine()).equals("exit")) {
if ("player".equals(key)) {
person = new Player();
} else if ("dancer".equals(key)) {
person = new Dancer();
}
haveFun(person);
}
}
public static void haveFun(Person person) {
//write your code here
if (person instanceof Dancer)
{
void dance();
}
else if (person instanceof Player)
{
void play();
}
}
interface Person {
}
static class Player implements Person {
void play() {
System.out.println("playing");
}
}
static class Dancer implements Person {
void dance() {
System.out.println("dancing");
}
}
}