Simon Sun

+ Follow
since Dec 07, 2000
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Simon Sun

How come, you guys don't use observe and mediarotar. I think it is popular. I don't know.
I admit I think certain pattern applying for certain case.
you can buy any OO software engineering book, which will talk about the UML. And right now, they are making big money.
Have someone read about the book "design patterns" which is written by Erich Gamma etc. It is really good book.
hopefully, I can get this week's book for free. I am interested in this topic. If someone are interested in this topic, we can share our experience.
Hi Pal,
the program is below:
public class SerialMe{
private static int numberOfMe;
private String myName;
public static void main(String args[]){
SerialMe serialMeList [10]; %line 5 error here
for( int i=0; i<10; i++){
serialMeList[i] = new SerialMe();
serialMeList[i].numberOfMe = i;
for( int i=0; i<10; i++){
System.out.println("serialMeList["+i+"].numberOfMe is"+ serialMeList[i].numberOfMe);
I got the error message like this.
--------------------------- Compiler Output --------------------------- ']' expected
SerialMe serialMeList [10];
1 error

21 years ago
don't understand your answer.
I write a program to test your result.
I can't compile it.
public class SerialMe{
private static int numberOfMe;
private String myName;
public static void main(String args[]){
SerialMe serialMeList[10];
for( int i=0; i<10; i++){
serialMeList[i] = new SerialMe();
serialMeList[i].numberOfMe = i;
for( int i=0; i<10; i++){
System.out.println("serialMeList["+i+"].numberOfMe is"+ serialMeList[i].numberOfMe);
The error message is :
can't specify array dimension in a type expression.
what is wrong with my program?
Suppoesd, I guess your answer is numberOfMe should be 10.
I don't know the result. However, if you remove the private
modifier, what is the result?
Last term, I took distributed system course. It is night mare for
me. I couldn't find the info from the net. I guess RPC is the
previous version of RMI. Right now, RMI evolves JINI?
Jini support WAP?
21 years ago
This question I am thinking about for a quite while.
I use java for a while and c++ as well.
Regarding OOP, I prefer java, its concept is so clear and
easily understandable. With respect to the performance,
I prefer C++. Even I am much more familiar with java, and
preparing for SCJP2 exam. And the job market of java seems
more bright. The merging of C# would give java a threaning?
Some one can give me a clue.
I really dislike the applet performance. Every time, I open
the web page with applet, it costs a lot of time. I am using
cable, I still wait for a long time. I can't image users using
dial-up painness.
I think java has portable advantage. No one can beat it.
21 years ago
This is interesting question.
I always have questions.
See this code.
public class Test {
public static void main(String args[]) {
StringBuffer a = new StringBuffer("One");
StringBuffer b = new StringBuffer("Two");
System.out.println("a = "+ a +" & b = " + b);
static void swap (StringBuffer a, StringBuffer b) {
a.append(" more");//copy of reference: line1
b.append(" confused");//copy of reference : line2
System.out.println("In method swap: a="+a+" b="+b);
b.append(" less");// copy of reference : line3
it seems that method append() directly apply reference of a,
rather than the copy of reference. Right?
So my question is that suppose there are a collection of methods
apply directly the reference of objects. Can I get what they are?
Or where I can get them?
Another question is that what benefits are if we use pass reference by parameters. Can you give me your exampls?
Hi pals,
I pop up the question about Madhu's code.
I borrow his code, hope he won't mind.
Button btn;
btn=new Button("Good");
public void replacer(Button replaceMe){
replaceMe=new Button("Evil");
/******output is Good
TextField tf;
tf=new TextField("Yin");
public void changer(TextField changeMe){
/*****output is Yang
My question is what the reference exactly is? As I understand it,
it refer the address of memory. some experts say that when we pass object in the arguments, we pass the copy of reference.
I am confused. the copy of reference is still pointing to the same memory location. so we change it, we change both.
So the both cases above should been changed.
Hope someone can throw me a light.
I really like this web site.
your first case is ok. I saw it in the book.
Your second case is the "protected" causing the problem.
Try to think protected means that classes in the same package and detrieved classes
can access that class. So when some classes in the same package access the class which
hasn't been initialized, so the blank final variable hasn't been initialized.
Am I say something wrong? I hope some expert can give us a claration as well.
Hi Vivek,
Good question. I got the same confusion before.
Remember, call by array pass reference, call by primitive type passing value.
public class Test{
public static void main(String args[]){
int i = 10;
Changer c = new Changer(i,args);
System.out.println("this is i :"+i+" in main.");
System.out.println(args[0] + "" + args[1]);
static class Changer{
void method(int i, String s[]){
int iC = ( i-1);
...//as yours
the output is: this is i: 10 in main
Mouse Mighty
i passed by value, array passed by reference.
Hopefully, it helps.
I suppose if you pass a class in arg, still pass by referece(this point is I guess, but I believe it is true).
Hi Bill,
I don't think we need initialize the primitive type.
Say int is primitive type, it will be initialize to 0. The
boolean type should be initialize to false automatically,
if there is no initialization.
I read it from JQplus. Many cases talk about the implicit
Am I wrong? Or say the local variable doesn't support implicitly
Which code fragments will print the last argument given on the command line to the standard output, and exit without any output and exceptions if no arguments are given?
the answer includes :
public static void main(String args[ ])
try { System.out.println(args[args.length-1]); }
catch (ArrayIndexOutOfBoundsException e) { }
if there is no arg, there is no exception?
regarding question 1.
the answer is 1.
I compile it and run it. I got it.
I don't get any official explaination.
I guess that assignment "=" is higher priority than "++"?
I read the explaination about the priority about the thread.
" the Thread gets the same priority as the thread that has created it."
I am confused about this.
Say, thread A create thread B. A and B have the same priority?
Another question:
class A extends Thread{
class B extends Thread{
class C{
public static void main(String[] args){
A a= new A();
B b= new B();
Is there anything talking about the priority about thread A and thread B?
Thanks in advanced
happy new year to all of you.
Thanks for your work.
I really really appreciate your work.
Good job.