Xinhua Gu

Greenhorn
+ Follow
since May 28, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Xinhua Gu

Hi, everybody,

i would like to use the code style described in http://www.javaranch.com/styleLong.jsp
(not sun's code style)

and how can i use this code style in Eclipse?

sofar i konw that in eclipse there is a fomatter tool, through that i can also import code style xml in eclipse.

Then, i want to know, if there is any available code style definition xml which differs from sun's ?

Thanks in advance !
Hi, everybody,

i would like to use the code style described in http://www.javaranch.com/styleLong.jsp
(not sun's code style)

and how can i use this code style in Eclipse?

sofar i konw that in eclipse there is a fomatter tool, through that i can also import code style xml in eclipse.

Then, i want to know, if there is any available code style definition xml which differs from sun's ?

Thanks in advance !
16 years ago
Thank you Trivedi. I congratulate you too. Today is a wonderfull day.
18 years ago
I cleared SCJP1.5 today afternoon also After 6 weeks preparation i got 86%.

Many thanks to K&B and all the ranchers here.This forum is great!!
18 years ago

class A implements Runnable {
public void run() {System.out.print(Thread.currentThread().getName());}
}
class B implements Runnable {
public void run() {
new A().run();
new Thread(new A(),"T2").run();
new Thread(new A(),"T3").start();
}}
class C {
public static void main (String[] args) {
new Thread(new B(),"T1").start();
}}


Please explain me why the o/p here is T1T1T3



new A().run(); and new Thread(new A(),"T2").run(); did not create new thread, they only print out the current thread name "T1"

after new Thread(new A(),"T3").start(); new thread "T3" is created.
actually, i donot like the "hiding" explanation from FAQ.

In my preceding codes, defining static method in subclass follow all the rules for legal overrides at compiler level e.g. it can not contain more strict visibility or it can not throw an Exception arbitrarily. Thus, it is NOT a redefined method. (in K&B page 147 says it IS redefined)

It JUST does not work for run-time polymorphism.

So, the bottom line is how to understand "can not be overridden".
For final method, "can not be overridden" means a compile error
Here, for static method it means "does not work for run time polymorphism"

Am i right?

Thanks for all the help.
[ May 31, 2006: Message edited by: Xinhua Gu ]
i wrote following code to see if this statement is true:
Static methods can not be overridden.


I think line 1 is an overriding method not a redefined method. To proof it, i changed line 1 to:
static synchronized void go(final int� a) throws Exception
Then compiler starts to complain...

Static methods can not be overridden,REALLY?
[ May 30, 2006: Message edited by: Xinhua Gu ]
Now i understood.. Thank you very much!
on page 754 (answer of Q15):
"....B,D,E and G could all happen because instance methods and static methods lock on different objects, and do not block each other"

Which objects that means..?

the object of an instance method ( void a()) : this ?
the object of a static method ( static void b()) : ThreadDemo.class ?

If "void b()" is not a static method,say an instance method like a(), "B" and "E" will be also the correct answers,am I right?

thanks
[ May 28, 2006: Message edited by: Xinhua Gu ]