假设我有两个班Parent,并Child和Child来自继承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) 我遇到了问题.我需要在Oracle 11g中创建一个过程,该过程将从给定行获取URL并从该URL下载文件并将其保存在blob类型列中.你能告诉我我的方法应该是什么来达到这个目的吗?
我想把主线程作为守护程序线程,但它告诉我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)