nedpals/errgoengine

[ERROR TEMPLATE] Java - ... in ... cannot be applied to

Closed this issue · 0 comments

Name Type Code Language
... in ... cannot be applied to Compile-time Error java.lang.CannotBeAppliedError Java

Description

The method or operation cannot be applied to the given arguments or context.

Sample Code

// CannotBeApplied.java
public class CannotBeApplied {
    public static void main(String[] args) {
        String text = "Hello";

        // Method 'charAt' cannot be applied to String with arguments
        char firstChar = text.charAt(0, 1);
    }
}

Sample Error Message

CannotBeApplied.java:7: error: method charAt in class String cannot be applied to given types;
        char firstChar = text.charAt(0, 1);
                             ^
  required: int
  found: int,int
  reason: actual and formal argument lists differ in length
1 error

Implementation Checklist

  • Implemented analysis
  • Implemented explanation translation
  • Implemented bug fix generation
  • Add tests