I am getting the error java:35: error: illegal character: \29, all this should do is when a user clicks on the label it changes from “H” to “T”
I am also getting error: ‘;’ expected
}
and error: reached end of file while parsing
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Lab3Label extends JLabel{
Lab3Label () {
this.addActionListener(new FlipTheCoinListener());
}
public void FlipTheCoin(){
int count = 0;
if(count % 1 == 0 ){
this.setText("H");
count += 2;
}
else{
this.setText("T");
count -= 2;
}
}
}
class FlipTheCoinListener implements ActionListener{
public void actionPerformed(ActionEvent e){
this.FlipTheCoin();
}
}
^ is the line in question
You have a funny character on that line, as evidenced by the actual error you’re getting, complaining about
\29. It may be because you cut and pasted the code in from somewhere with the extraneous character.If you really wanted to investigate properly, you could examine the hex contents of the file such as with (UNIXy systems):
but it’s probably easier just to delete the line totally and retype it.