HI, friends
I am studying Java. I am stuck by my another friend. he asked me 2 problems when I think I have grasped the main points of Java language. How about you?
The 2 problems are the following:
1) the following code can run. right?
class MainClass{
public static void main(String[] args){
Object o = new Object();
o.finalize();
}
}
I definitely say there is compile error, but I donot know why?
2) Thread problem
class MainClass2{
private static void main(String[] args){
Thread t = new Thread();
t = Thread.currentThread();
t = null;
System.out.println("We run");
}
}
private accessity can help main method run? why? thread t , which is main thread , has been assigned null, can the print statement be excuted? why?
Can u help me?To Jabber and other friends.
RanchHand
I am studying Java. I am stuck by my another friend. he asked me 2 problems when I think I have grasped the main points of Java language. How about you?
The 2 problems are the following:
1) the following code can run. right?
class MainClass{
public static void main(String[] args){
Object o = new Object();
o.finalize();
}
}
I definitely say there is compile error, but I donot know why?
2) Thread problem
class MainClass2{
private static void main(String[] args){
Thread t = new Thread();
t = Thread.currentThread();
t = null;
System.out.println("We run");
}
}
private accessity can help main method run? why? thread t , which is main thread , has been assigned null, can the print statement be excuted? why?
Can u help me?To Jabber and other friends.
RanchHand