Pierre Post

Greenhorn
+ Follow
since Jun 18, 2002
Merit badge: grant badges
For More
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 Pierre Post

Why not simply replace the "\n" after parsing? You loop through the string and if you encounter the text "\\n" (don't forget to escape the backslash) you replace it by the character '\n'.
Pierre
21 years ago


we can't write,
Class.forName("blah..blah..blah...").staticMemberName;
right?


Have you tried to use the getDeclaredField() method from the "Class" class? I think it also returns static fields, but I haven't tried yet.
Something like:
Class.forName("blabla").getDeclaredField("fVersion").getInt(null);
A Field provides information about, and dynamic access to, a single field of a class or an interface. The reflected field may be a class (static) field or an instance field.
Pierre
[ November 29, 2002: Message edited by: Pierre Post ]
21 years ago
There are two possibilities I might suggest:
- You may first convert your value from double to long and then output the long value.
- You may use the class java.text.DecimalFormat to format the output of your double value.
Pierre
21 years ago
In fact, a method can throw runtime exceptions without declaring them in the method signature.
Thus,

would successfully compile.
Pierre
21 years ago
I passed the SCJP exam this morning with 98% :-D
I got tough questions about flow control and threads (I missed the one question in this section). Also some detailed questions about the Java packages.
Thanks to everybody on this forum. Great place!
21 years ago
I just wanted to show why any Runnable given with the constructor is ignored when you override the run() method.
I don't know, there could have been e.g. a test in the start() method that if a Runnable object has been given its run method will be executed or something like that. But forget this as start() is a native method.
Here is the run() method of the Thread class:

So, if you override the thread's run method, the passed Runnable parameter given with the thread constructor is ignored.
Finally, the result is that nothing is printed if your code is executed.
[ June 20, 2002: Message edited by: Pierre Post ]
It is perfectly legal to add a class declaration to an interface body according to the JLS (�9.1.3).
Moreover, default modifier is static, so to instantiate the class you type

However, "Initializer blocks cannot pass on checked exceptions, only unchecked ones." -- Mughal&Rasmussen pg 259, 8.2 Initializers


... "unless that exception or one of its superclasses is explicitly declared in the throws clause of each constructor of its class and the class has at least one explicitly declared constructor. An instance initializer in an anonymous class can throw any exceptions." (JLS �8.6)
I think this is important as I had one or two mock exams where this was asked.
Ok, after several discussions I have come to the conclusion that the correct answer would be 0 or 3, but impossibly 1. Never trust 100% the answers of mock exams ;-)
Thank you all for your help!
Thank you for your response. That is what I have expected.
But to return to the mentioned example, wouldn't the correct answer then be 0 (i.e. no string is eligible for garbage collection)? Otherwise, if we suppose the JVM exits after the few lines of code, the answer would be 3, no?
During my preparation for the SCJP exam I have come across a type of question for which I don't agree with the given answers.
The question shows a code extract (not an entire program) where several strings are created/accessed in the string pool. Then, it asks how many objects are eligible for garbage collection after line xy.
But I thought that strings from the string pool are only eligible when the JVM exists
Here's an example from MindQ's exam:
String name;
String newName = "Nick";
newName = "Jason";
name = "Frieda";
String newestName = name;
name = null;
//Line A
Answer is 1 object eligible for garbage collection ???
Thank you to anybody who might push me in the correct direction