Bill Tripper

Greenhorn
+ Follow
since May 30, 2001
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
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Bill Tripper

Originally posted by Dominic Mack:

The finalize() method is guaranteed to be called on any object to be GC�ed


The key point here is "any object to be GC'ed." It's true that we cannot guarantee that any object will ever be GC'ed, but what this question is talking about is what happens once the system decides to GC something. If the JVM decides an object is to be GC'ed, the finalize method will be called, assuming it hasn't been called previously.
Bill
18 years ago

but you should see what the monkeys in thailand do... there aren't any rules there!


Actually, the monkeykeepers in Thailand are cracking down. No nudity, closing at 1:00 AM. The police chief in the Patpong district got sacked for allowing a monkeyhouse to be open late. Of course, you're still allowed to touch, unlike in the USA.
18 years ago

Originally posted by Thomas Paul:
[B]What part is confusing:

[/B]


FWIW, On my Win NT box, I get the following:
c=?
D=Process Exit...
Bill

I guess the short answer is no. The Round Up is not comparable to the real test.

Originally posted by Cindy Yang:
can anybody explain in detail how to do following code? I have trouble when using shift operator on negative.
int i = -8, j = -8;
i >>= -4;
j >>= -34;
i=?
j=?
Thanks.
Cindy


Both i and j end up as -1.
i >>= -4 is equivalent to i >>= 28.
j >>= -34 is equivalent to j >>= -2 is equivalent to j >>= 30.
Note that the >> shift operator will fill in the sign bit, that is, as values are shift to the right, the leftmost bits are all filled with ones.
In your example, i = -8 which is binary 11111111111111111111111111111000. Then >> -4 is the same as >> 28 which yields binary 11111111111111111111111111111111, or decimal -1. Next j = -8 which is binary 11111111111111111111111111111000. Then >> -34 is the same as >> -2 which is the same as >>30 which yields binary 11111111111111111111111111111111, or decimal -1.
Your example would be more interesting if you did

which yields the result:
i = 15, j = 1073741822
by the following logic.
i = -8 is binary 11111111111111111111111111111000.
Shift it -4 is the same as shift it 28 which is binary 00000000000000000000000000001111 which is 15.
j = -8 which is binary 11111111111111111111111111111000
Shift it -30 is the same as shift it 2 which is binary 00111111111111111111111111111110 which is 1073741822.
Bill
18 years ago
From http://www.go4java.20m.com/index.htm I encountered the following question:
Q27.What will be the result of compiling and running the given program?
Select any two.

1. Compile time error as Date class is defined in both of the above packages.
2. Run time error as Date class is defined in both of the above packages.
3. It will compile and run without any error.
4. It will compile and run if we use .Date instead of .* in any one of the two import statements
The answers given are 1 and 4. I believe that answer 4 is incorrect. If you change the import statement to "import java.sql.Date", then you get a compile error as the java.sql.Date class specifies no constructor without an argument. That is, you can't have "java.sql.Date d = new java.sql.Date()". Of course, if you specify "import java.util.Date", then the program will compile.
Bill
18 years ago
Theres probably a function to do this which I couldn't find, but how about:
x = Math.round(x * 100) / 100.0;
If x is a double, this will round it to 2 decimal places.
18 years ago
Now I'm feeling old. I've been programming for 28 years. I'm 45 and started on a time share machine, programming FORTRAN, in high school. I spent ten years doing C and C++, and got hired to do Java last November.
18 years ago
I too, was raised Catholic and also consider myself without any religion. I found the high score for Theravada Buddhism (as opposed to other forms of Buddhism) was interesting as I've recently become interested in that form of Buddhism.
1. Unitarian Universalism (100%)
2. Secular Humanism (87%)
3. Neo-Paganism (86%)
4. Theravada Buddhism (84%)
5. Liberal Quaker (83%)
6. Atheism and Agnosticism (75%)
7. Mahayana Buddhism (73%)
8. Jainism (71%)
9. Hinduism (67%)
10. New Age (66%)
11. Reform Judaism (64%)
12. Sikhism (63%)
13. Bah�'� (61%)
14. New Thought (59%)
15. Islam (58%)
16. Orthodox Judaism (58%)
17. Liberal Protestant (57%)
18. Scientology (56%)
19. Taoism (52%)
20. Orthodox Quaker (48%)
21. Christian Science (Church of Christ, Scientist) (46%)
22. Conservative Protestant (36%)
23. Eastern Orthodox (26%)
24. Latter-day Saint (Mormon) (26%)
25. Roman Catholic (26%)
26. Seventh Day Adventist (22%)
27. Jehovah's Witness (20%)
18 years ago
Very interesting. I get the same thing with the other comment type, i.e., /* char mm = '\u'; */ also generates a compile error.
18 years ago

Originally posted by Peter Lyons:
"D'OH" is a contraction... for what?


Wow, I never would have known that. I mean, on the surface, "D'OH" and "for what?" don't seem to be related. You learn something new every day. Thanks for explaining that.
18 years ago
An abstract class can provide the bodies for least some methods. That is, only some of the class methods need be abstract. The remaining can be provided in the base (abstract) class. An interface requires that all methods be specified in the derived class which implements the interface. If I have an abstract class that provides no methods of its own, then I always think about converting it to an interface.
Also, a class which extends an abstract class, cannot extend any other class. A class which implements an interface can extend any class.
If your class has methods that are best implemented in the base class, use an abstract class. If all your methods are best implemented in the derived classes, consider using an interface as it is more flexible.
18 years ago

Originally posted by Alok Pota:
I would like to take two sets A & B and remove from the set B
all elements common to A & B. Is there a clean way to do this using java.util.Collections?


Assuming that A abd B both implement the Set interface (HashSet, TreeSet), you can just do:
B.removeAll(A);
If it ends up removing any objects, the method will return true. Also, the List interface has a removeAll method, so I think you're covered for any standard Java class implementing Collection. I don't think you need the Collections class.

18 years ago

Originally posted by Kaushik Badiyani:
String s1,s2,s3,s4;
s1="abc";
s2=s1;
s3=s2+"zzz";
s4=s3;
How many String objects are created ??
I think it is 2.


I think the answer is 3.
Clearly there is a String object (referenced by s3) that contains a String value of "abczzz". It obviously isn't a String literal. In addition, there are the two String literals. That makes a total of three String objects.

Originally posted by Richard Robbins:
How does one determine whether a String object contains a certain substring? The regionMatches functions won't do it. I need something that determines whether a given string contains a substring without regard for what the substring start and end indices are.


How about:
stringOne.indexOf(stringTwo) >= 0
18 years ago