JAVA Variable declaration not allowed here -


i error "variable declaration not allowed here" , don't know why, i'm new in java , can't find answer :/ says, can't make "int" in "if" there way create it?

import java.io.printwriter; import java.io.file; import java.io.filenotfoundexception; import java.util.scanner;import java.util.scanner;  public class test{   public static void main(string[] args) throws filenotfoundexception{     file plik = new file("test.txt");     printwriter saver = new printwriter("test.txt");       int score = 0;      system.out.println("q: what's bigger");      system.out.println("a: dog b: ant");      scanner odp = new scanner(system.in);      string odpo = odp.nextline();       if(odpo.equals("a"))         int score = 1;      else          system.out.println("wrong answer");    } } 

string must changed string.

by writing int score you're trying declare new variable exists, declared before already. remove int part , assignment want.


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -