2 problems .Finalize and Thread. who can answer?

guest (JavaRanchHand)
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();
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.

2001-1-5 -04:00
This post has been archived. It cannot be replied.
Page address has been copied. To share, click to copy page address.
Share Online by QR Code

Back To Topic: 2 problems .Finalize and Thread. who can answer?

Back To Forum: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论