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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • list转有序map「建议收藏」

    list转有序map「建议收藏」publicstatic<KextendsComparable<?superK>,V>Map<K,V>sortByKey(Map<K,V>map){ Map<K,V>result=newLinkedHashMap<>(); map.entrySet().stream() .sorted(Map.Entry.<K,V>c..

    2022年9月23日
    2
  • linux 如何查看mysql版本,Linux系统下查看mysql版本的四种方法

    linux 如何查看mysql版本,Linux系统下查看mysql版本的四种方法1:在终端下:mysql-V。以下是代码片段:复制代码代码如下:[shengting@login~]$mysql-VmysqlVer14.7Distrib4.1.10a,forredhat-linux-gnu(i686)2:在mysql中:mysql>status;以下是代码片段:复制代码代码如下:mysql>status;————–m…

    2025年5月31日
    1
  • vscode怎么html和php混编,vscode如何编译运行html文件[通俗易懂]

    vscode怎么html和php混编,vscode如何编译运行html文件[通俗易懂]首先打开我们的VSCode软件,然后新建一个HTML文件,注意,在VSCode软件里面新建一个文件,它的后缀名也必须写上这时候我们写好HTML内容之后,鼠标右键,发现没有运行HTML文件的按钮我们需要点击VSCode软件左边的“扩展”,或者同时按住键盘上的Ctrl+shift+I键进入“扩展”界面进入“扩展”界面之后,我们在搜索框内输入“open”,然后找到“openinbrowser…

    2022年8月21日
    12
  • matlab2016a安装教程win10(matlab2015安装教程)

    版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012313335/article/details/73733651 </div> <linkrel=”stylesheet…

    2022年4月12日
    302
  • Linux远程桌面连接黑屏

    Linux远程桌面连接黑屏本地 Win7 远程 linux 问题 使用 Win7 自带的远程桌面工具 连接后突然黑屏 本来用的好好的就不行了 重启可能解决问题 不重启重新进入还是黑屏 歪门邪道 网上有说清除位图缓存的 试了没用 名门正派 使用 XShell

    2025年11月5日
    3
  • 解决Pycharm下导入TensorFlow失败的问题[通俗易懂]

    解决Pycharm下导入TensorFlow失败的问题[通俗易懂]一般情况下通过:File—Settings—Project:工程名字—ProjectInterpreter—右上角加号–上面窗口输入Tensorflow—左下角的InstallPackage就可以成功导入。如果导入失败,可能是你的pip版本不够用了,按照上述方法,先把pip更新一下,在去导入TensorFlow可以了。…

    2022年8月26日
    5

发表回复

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

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