cannot be applied to

傷城~ 2022-06-08 01:59 287阅读 0赞

错误示例:

这里写图片描述

代码块

  1. public class Test {
  2. public static void main(String[] args) {
  3. test(111);
  4. }
  5. public static void test(String str) {
  6. System.out.println(str);
  7. }
  8. }

错误分析

test(String str)传入String类型的变量,所以非String类型的变量不能applied到Test类的test(String str)方法上。

错误解决

这里写图片描述

总结

cannot be applied to 这种错误是由于传入的参数类型不相符

发表评论

表情:
评论列表 (有 0 条评论,287人围观)

还没有评论,来说两句吧...

相关阅读