• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help  RSS feed

 
Bob Tesaw
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm new to Java, and I'm not very sure if this question goes to beginners or intermediate... Sorry if I chose wrong...

I need help on a try and catch block...

class something implements ActionListener {
something() {
//some swing code, including a button
}
public void actionPerformed(ActionEvent e) {
try {
//code for block
} catch(Exception e) {
//some code
}
}

class sometingElse {
public static void main(String args[]) {
new something();
}
}

When I compile this, there is an error that "e" in the
public void ActionPerformed(ActionEvent e) is already defined, and won't accept (Exception e). What is the problem please?

Thank you...
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


You're trying to name both your action event and the exception 'e'.
Try naming the exception something else like 'ex'.
 
Bob Tesaw
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!