小编sti*_*ing的帖子

java可以在其他对象中调用父重写方法但不能调用子类型吗?

这是工作的java代码

class Cup {
    public String sayColor() {
        return "i have a color .";
    }
}

class TCup extends Cup{
    public String sayColor(){
        System.out.println(super.getClass().getName());
        return super.sayColor()+"color is tee green.";
    }
}

class MyTCup extends TCup {
    public String sayColor(){
        System.out.println(super.getClass().getName());
        return super.sayColor()+"but brushed to red now!";
    }
}
class Test {
    public static void main(String[] args) {
        Cup c = new MyTCup();
        System.out.print(c.sayColor());
    }
}
Run Code Online (Sandbox Code Playgroud)

并运行Test类打印

MyTCup
MyTCup
i have a color .color is tee green.but brushed to red now! …
Run Code Online (Sandbox Code Playgroud)

java overriding

36
推荐指数
1
解决办法
8万
查看次数

egit和git unstaged文件显示不同的状态

我使用git svn fetch svn repo,然后执行clone-> branch-> rebase-> merge-> dcommit step.with eclipse egit和cygwin client,做几天开发一切都没关系.

但有一天,在一个merge/dcommit步骤之后,我发现eclipse egit阶段视图状态与cygwin命令行中的git状态不同.当eclipse中的某些文件未分段更改时,cygwin'git status'显示没有任何更改;如果提交了egit in elcipse,cygwin命令'git status'显示未提交的文件已更改为刚提交的egit.and如果提交更改与cygiwn git客户端,egit显示相同的阶段文件已更改.问题文件始终是一些文件.

我使用吹法,但无用的git reset --hard.从svn到eclipse项目,重新放入svn repo .importing new cloned repo,它显示文件在启动时被更改,并且始终是那些文件.

任何人帮忙!!

git git-svn egit

5
推荐指数
1
解决办法
963
查看次数

标签 统计

egit ×1

git ×1

git-svn ×1

java ×1

overriding ×1