Wednesday, May 11, 2022

It Has Been a Long Time Since I Wrote Java

 package ArgTypes;

enum argumentValueTypes (double=0, bool=1, int=2);

// Constructor of individual pairs of argument names and types

public class ArgTypes 

{

// Instance

String argName;

argumentValueTypes argumentValueType;

// Constructor of each pair

public ArgTypes (String argName, argumentValueTypes argumentValueType)

{

this.argName = argName;

this.argumentValueType = argumentValueType;

}

}

The error messages:

Multiple markers at this line
- The declared package "" does not match the expected package 
"ArgTypes"
- The import ArgTypes cannot be resolved
- Syntax error, insert ")" to complete Arguments
- Syntax error on token "=", ( expected

What does this mean?  There is no package "".  I think it is automatically creating imports for class ArgTypes.

1 comment:

  1. Java expects package members to be in subdirectories named after the package. In this case, you have a source directory with ArgTypes.java in it, and Java wants you to move it into a subdirectory named ArgTypes. At a guess, the other errors are either fallout from the first, or else the compiler can't find class argumentValueTypes (possibly because of a package mismatch?)

    ReplyDelete