-2

I got following lines of code:

for (int i = 0; i < articles.length(); i++) {
  static {
    addItem(new JsonParserItem("1", R.drawable.p1, "asd", "Steve Jobs", "Focusing is about saying No."));
  }
}

After static I get a red marker (error) which tells me

identifier or type expected

how can I solve this

Ivan
  • 34,531
  • 8
  • 55
  • 100
Alex Oxilg
  • 121
  • 1
  • 8

2 Answers2

0

Why do you have a static block in there? That's supposed to be under a class, not inside a for loop.

Remove that and your syntax error should disappear:

   for (int i = 0; i < articles.length(); i++) {
       addItem(new JsonParserItem("1", R.drawable.p1, "asd", "Steve Jobs", "Focusing is about saying No."));
   }
Sameer Puri
  • 987
  • 8
  • 20
0

Static should not be inside a method. See the following question for more information on how to use Static in Java : What does the 'static' keyword do in a class?.

Community
  • 1
  • 1
TKManta
  • 1
  • 1