abstractmethoderror:某方法_error parse true

abstractmethoderror:某方法_error parse trueAbstractMethodError:Thisjava.lang.AbstractMethodErrorisusuallythrownwhenwetrytoinvokethe

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

AbstractMethodError:

This java.lang.AbstractMethodError is usually thrown when we try to invoke the abstract method.

we know that an abstract method cannot be invoked and if we try to do so then you will get a compile-time error.So you may think how this error is thrown at run-time?.

The reason is binary incompatibility-what does it mean?

     Whenever a class is modified,other classes that refer to this (modified) class will not be aware of the changes made in it.So all the classes must be compiled as a whole.If not then you may encounter one of the subclasses of incompatible class change error.

“This error indicates that the method that you invoke is converted into an abstract method now”.

see the following example to have an idea about this error

class B
{
public void display()
{
System.out.println(“I am inside B”);
}
}

import java.util.*;
public class A extends B
{
public static void main(String args[])
{
A a=new A();
a.display();
}
}

output:

C:\blog>javac A.java

C:\blog>java A
I am inside B

Now i am going to convert the display() method as an abstract method and compile it alone.

abstract class B
{
public abstract void display();
}

Output:

C:\blog>javac A.java

C:\blog>java A
I am inside B

C:\blog>javac B.java

C:\blog>java A
Exception in thread “main” java.lang.AbstractMethodError: B.display()V
at A.display(A.java:3)
at A.main(A.java:8)

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/167044.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • PathFileExists用法--使用#include <shlwapi.h>

    PathFileExists用法--使用#include <shlwapi.h>BOOLPathFileExists(LPCTSTRpszPath);Determinesifafileexists.—经检测,该函数可以检测文件或目录是否存在!RemarksThisfunctionteststhevalidityofthefileandpath.Itworksonlyonthelocal…

    2022年7月12日
    12
  • MySQL安装及配置详细教程

    MySQL安装及配置超详细教程首先下载安装包[网址](https://dev.mysql.com/downloads/file/?id=476233)进入页面后可以不登录。后点击底部”Nothanks,juststartmydownload.”即可开始下载。安装:直接把压缩包解压到你想安装的路径即可,相当于不用安装,可以看到我的解压路径在D盘的ROUTE文件夹下的mysq…

    2022年4月8日
    50
  • 内网ip和外网ip区别

    内网ip和外网ip区别文章一:原文:https://blog.csdn.net/Alexwym/article/details/81772446我们每天都会访问各种各样的网站,比如淘宝,百度等等。不免会思考,我们的设备是如何连接上这些网址的呢?要想搞清楚这个问题,首先就得先搞清楚内网ip和外网ip的联系。如图,假设我们的计算机现在就是设备一,我们想要访问百度。如果我们正使用着校园网,那么首先我们需要先通…

    2022年6月14日
    37
  • 精通Web Analytics 2.0 (4) 第二章:选择你的网络分析灵魂伴侣的最佳策略

    精通Web Analytics 2.0 (4) 第二章:选择你的网络分析灵魂伴侣的最佳策略精通WebAnalytics2.0(4)第二章:选择你的网络分析灵魂伴侣的最佳策略   精通WebAnalytics2.0:用户中心科学与在线统计艺术第二章:选择你的网络分析灵魂伴侣的最佳策略  在WebAnalytics2.0的新…

    2022年6月28日
    16
  • 4.4.2分类模型评判指标(一) – 混淆矩阵(Confusion Matrix)

    4.4.2分类模型评判指标(一) – 混淆矩阵(Confusion Matrix)简介混淆矩阵是ROC曲线绘制的基础,同时它也是衡量分类型模型准确度中最基本,最直观,计算最简单的方法。一句话解释版本:混淆矩阵就是分别统计分类模型归错类,归对类的观测值个数,然后把结果放在一个表里展示出来。这个表就是混淆矩阵。数据分析与挖掘体系位置混淆矩阵是评判模型结果的指标,属于模型评估的一部分。此外,混淆矩阵多用于判断分类器(Classifier)的优劣,适用于…

    2022年5月14日
    51
  • Android – match_parent 和 fill_parent差异

    Android – match_parent 和 fill_parent差异

    2022年1月2日
    48

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号