-1

I'm trying to declare the following method:

 public void catch(Entity ball) {
}

But I get the following error: Syntax error on token "catch", Identifier expected.

Is there anyway to resolve this?

  • I think catch is a reserved word, so the answer would be no. – Lexi Aug 18 '17 at 18:49
  • 2
    Have you reviewed questions before asking? Also take a look at the [tour] and the [help] to learn how to ask better questions to minimize the downvotes. The tour was presented when you created an account. There have been some who haven't bothered to read it even though it provides useful information. – Lexi Aug 18 '17 at 18:53
  • 1
    @CareyOn Looks like you don't understand what a downvote's purpose is. Please read the Help Center to better understand the site's features. – Sotirios Delimanolis Aug 18 '17 at 18:53
  • 2
    That's not true. It's very clear in your profile that you've asked questions that aren't downvoted. Besides, they're just fictional points on a website. – Kayaman Aug 18 '17 at 18:58
  • @CareyOn Also take a look at [ask], and how to create a [mcve]. And always search ([**a lot**](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users)) before asking to avoid being marked as duplicate. –  Aug 18 '17 at 18:59

3 Answers3

4

No. You can't use any of the java keywords.

Juan Carlos Mendoza
  • 5,736
  • 7
  • 25
  • 50
3

catch is a reserved word in java take a look here Java Language Keywords, so if you use any of the words in the the list you still get the same error

Youcef LAIDANI
  • 55,661
  • 15
  • 90
  • 140
0

No you cannot use language keywords as method names

fmatar
  • 3,490
  • 1
  • 15
  • 11