小编Har*_*pta的帖子

Java中的继承真的发生了什么?

假设我有两个班Parent,并ChildChild来自继承Parent.我有三种方法Parent,其中两种是公开的,一种是私人的.

通常我们说所有非私有方法都被继承到Child类中,但我对确切发生的事情感到困惑.Java是否在Child类中复制了这些方法,还是使用某种引用来维护关系?

class Parent{
    // Private method
    private void method1(){
        System.out.println("In private method of Parent class");
    }
    void method2(){
    // calling private method
        method1();
    }
    void method3(){
    // calling private method
        method1();
    }
}

class Child extends Parent{

}

class MainClass{
   public static void main(String[] args){
       Child child = new Child();
       // calling non-private method which internally calls the private method
       child.method2();
   }
}
Run Code Online (Sandbox Code Playgroud)

java inheritance

22
推荐指数
2
解决办法
1926
查看次数

从Oracle 11g中的给定URL下载文件并将其保存到blob类型列的过程

我遇到了问题.我需要在Oracle 11g中创建一个过程,该过程将从给定行获取URL并从该URL下载文件并将其保存在blob类型列中.你能告诉我我的方法应该是什么来达到这个目的吗?

database oracle plsql stored-procedures oracle11g

2
推荐指数
1
解决办法
6954
查看次数

如何在Java中将主线程作为守护程序线程?

我想把主线程作为守护程序线程,但它告诉我IllegalThreadStateException.有没有办法做到这一点?

public class DeamonThreads {

    public static void main(String[] args) {
        System.out.println("Main Started");
        System.out.println("Thread type deamon = " + Thread.currentThread().isDaemon());
        Thread.currentThread().setDaemon(true);
        System.out.println("Thread type deamon = " + Thread.currentThread().isDaemon());
        System.out.println("Main End");

    }
}
Output

Main Started
Thread type deamon = false
Exception in thread "main" java.lang.IllegalThreadStateException
    at java.lang.Thread.setDaemon(Thread.java:1367)
    at com.threads.DeamonThreads.main(DeamonThreads.java:8)
Run Code Online (Sandbox Code Playgroud)

java multithreading daemon

0
推荐指数
1
解决办法
2910
查看次数