Home > Back-end >  Error Code while writing a Snake Game with Java
Error Code while writing a Snake Game with Java

Time:12-15

I recently started to teach myself some Python and Java. So I tried to write some easy programs but with this snake game I tried I discovered a mysterious problem. Maybe someone of you knows where the error is.

the code:

for(var i = 0; < snake.tail.length;i  ){
...

If you need something else to engage this problem please let me know

Julian

CodePudding user response:

you're missing an "i", and java doesn't use var, use int instead:

for(int i = 0; i < snake.tail.length; i  ){

CodePudding user response:

In your code, you have the wrong condition construction:

   < snake.tail.length
^
|
|

You don't have anything on the left site. Probably you need the i variable here.

i < snake.tail.length
  •  Tags:  
  • java
  • Related