Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!

Wong Martin

Greenhorn
+ Follow
since Jan 14, 2011
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Wong Martin

Hi Campbell,

Thanks for your reply!

I just met the problem as you've mentioned, my CLASSPATH is getting longer and longer by setting too many variables , and sometime even duplicated because of neglect. In my case, they just
work fine. Do you know the way of removing those paths I've duplicated in the CLASSPATH??

My solution to this issue (not that smart anyway ) is simply put these two lines into ~/.bashrc file:

unset CLASSPATH
export CLASSPATH=$CLASSPATH:a/new/path/for/it

The Shell can get rid of the old one, and always only point to the second line I set. Is there any straightforward way?

Martin
8 years ago
Hi Kumara, Holloway,

Sorry for my late reply.

Thank you for the solutions

I'd included the servlet-api.jar into my CLASSPATH environment indeed. I found it most convenient.

My way is typing this command on my shell: export CLASSPATH=$CLASSPATH:/path/to/my/servlet-api.jar

I didn't actually realize why, but somehow I could solve the problem by typing in command-line instead of editing etc/profile... anyway, thanks for the helps!~

MartinSing.
8 years ago
Hi buddies,

I'm new to Servlet and Linux, using Tomcat on Fedora15. I need help...

How can I include servlet-api.jar to java classpath, in order to be more comfortable with compiling .java file? I've tried some like:

1. edit etc/profile
2. edit etc/java/java.conf
3. drag and drop the servlet-api.jar file into jdk_/jre/lib

Unfortunately, none of these methods have solved my problem... What is the right way? It's really cumbersome for typing javac -classpath path/some/what/abc.jar everytime...

Please,
Martin
8 years ago
Hi Everyone,
Coding for practice today and finally have come up a question about Thread:

These codes will be executing normally and print out the result: "I kill.. t1", but if I uncomment line 8 and 11 and then comment line 7 and 10, the result will become infinite "t2 can't be stopped..".
I guess this refer to the matter of constructor which I used, but I just couldn't find out the answer..
Can anyone help me?? Thank you!
Thanks Aditya! Apologize for my late reply..
""The only reason you can leave the parameter types out is because of backwards compatibility. If Java was designed with generics from the start, you wouldn't even have been able to leave parameterization out. ""

I haven't recognized that you had already explained the reason of my question!
Sorry for I was stupid~
Stephan,

You resolved all my doubts! Thank you for your patience!!

What is the relation between "ArrayList <Integer> al; // ArrayList al; " and "new ArrayList <Integer> ();"??

Actually, I couldn't understand the intention of such programming syntax when I first saw them and have no idea about its history. Now it all makes sense after your explanation.



Stephan,

You hit the point which I was trying to say. No doubt I used a wrong way in generic type for those cases, and this is exactly what I was trying to say. Why does Java offer its user an opportunity to be wrong? I mean if we compare the features between generic-type and polymorphism:



This is incomparable in logic for sure; however, it came up with some questions to me. Why? Why did the inventors of Java make this happen? Any usage for programming (Line7)? Any reason? Any feature I haven't understood yet?? What is the relation between "ArrayList <Integer> al;" and "new ArrayList <Integer> ();"??
I am not focusing on right or wrong. It seems like Java has left programmer an option. This is my responsibility as a programmer to handle it in appropriate way, but as a student, I just want to make myself clear.
I hope this time my question has hit the point.
Thank you Brown! I should find out the answer myself in the API!
Hi Stephan,

Thank you! Perhaps my question wasn't clear...
Actually, I am trying to understand the usage of:



Why shoud I use it? It doesn't help, and by the way, just make me confused indeed:



Java is a strongly typed programming language; however, this made me wonder, how the generic type I declared after the keyword "new" works to help me, as Java itself also has a polymorphic mechanism? So:



What does it mean? And:



What is the relation between them (generic type)??

Thanks!!
Hi everyone,

Just wanna know the usage of generic type in object:



The code is trying to have fun with my question (not really funny though..). Anyway, my question is:

1. According to the polymorphism in Java, An object can pass by value in case we want it to be used by several times. So beside the consideration of safety reason, in java.util.Collection, what is the usage of declaring something like Set s = new HashSet <Integer> () ?? Once you use it in another place like HashSet hs = (HashSet)s, it doesn't really matter that whatever generic-type it is. For instance:


Even though the compiler will complain there is an unsafe operation or whatever it is, the code runs without error:



Even if we declare in a different generic type, it is still without a runtime problem (Or any hiding problems??). My question is, can I say that the generic type is somehow designed for the methods defined in Collection classes, instead of class itself?? Thank you!!
Hi everyone,

I practiced Collection classes today and found out an interesting thing (perhaps not that interesting to you..) :



The result printing out by different places will have a little bit difference depending on its executing order. I have tested for several times and here I have:

if (the thread's running first) {
A
s in Main [Thread[A, 5, main]]
Iterated: Thread[A, 5, ]

} else if (the println(s)'s going first (Thread.sleep(1000) is involved)):
s in main [Thread[A, 5, main]]
Iterated: Thread[A, 5, main] A

} else {
s in main [Thread[A, 5, main]]
A
Iterated: Thread[A, 5, ]
}

What is the 5? Where did it come from?
Thank you !!
Hi,

Today I read a set of code in the Internet and have a question:

What's the difference between abstract interface and interface? Thank you.