![]() Check file names and version histories carefully. It may seem hard to believe that you're reading a different source code than the one producing the error, but it's definitely possible, and especially for new Java programmers. Declaring this variable by specifying its data type (or, alternatively, inferring its type with the var keyword in Java 10+) resolves the issue (Fig. You're looking at the wrong source code. You will generally get this error, when you put code randomly inside a class rather than method. 1 (a) shows how an undeclared variable, in this case the identifier average on line 9, results in two instances of the cannot find symbol error, at the positions where they appear in the code.When i see your code, my first advise is to get a good IDE like Eclipse, IntelliJ or Netbeans, it will help you to see quickly the compilation errors. If you want to do random numbers you should try the Random class like this : Random random new Random () int numberToFind random.nextInt (2) You should take a look at the Java naming conventions, it helps to have a clean code that any. This problem can be hard to spot, but in this case, if the source files use UTF-8 encoding, you may be using some identifiers as if they're identical but really they're not because they simply appear to be spelled the same. I'am glad to see peaple learning Java, and i'am happy to see peaople helping the juniors. randnumber doesnt contains methods and yet tries to do conditions. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |