Campbell Ritchie

+ Follow
since Oct 13, 2005
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
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Campbell Ritchie

Is that the book by Jeanne Boyarsky and Scott Selikoff? Thank you for giving us the question number, but for those of us who don't have the book please copy the question. I can only answer your query if I know what the book says.
Having written a strongly- and statically‑typed language, I had to resist my supervisor's suggestions about getting keyboard input with ASK. That was in Forth, which is a weakly typed platform, so I saw ASK as meaning, “Goodbye type‑safety, and hello lots of segmentation errors.” It would have allowed users to enter anything at runtime and who knows what would have gone wrong.

You have similar problems with keyboard input in a strongly typed language, but at least you can reject incorrect input.
1 day ago
I am afraid that doesn't answer Norm's question.
1 day ago
Don't talk about virtual methods. That is a concept belonging to C++.
1 day ago
Bertrand Meyer wrote, I think in Object‑Oriented Software Construction, that C arrived as just the right language at the right time to take over from Pascal, etc. It has always been popular for writing operating system,s database management programs, etc. The Language of the Year accolade from Tiobe is because it showed the greatest rise in marks on the Tiobe index. I think the InfoWorld article may have been exaggerating in calling C faltering; I thought that despite its potential difficulties, C has always maintained popularity. I also think one of the reasons for lower percentages than a few years ago is that there are simply more languages and the marks are shared more widely.
1 day ago

Peter van der Werff wrote:Everyone,

thanks a lot . . .

That's a pleasure

I learned a lot

That is always good to hear, too
1 day ago

fred rosenberger wrote:. . . . are you supposed to move each integer as you find it  . . . . 

Or, if you find an odd number at the beginning, are you supposed to swap it with an odd number to its right?

I think the swapping of two elements in an array seems to be a common exercise, and I often suggest people write themselves a utility class with a swapTwoElementsInArray method.
1 day ago
You would only want to iterate the loop and test for equality if you have been told this is an exercise in writing loops. You would first have to ensure that whatever you are seeking has a correctly overridden equals() method (Strings do) and then use methods on the List like this or this. Note that in the case of Strings only, there is an alternative to the equals method: this.
1 day ago
You can also pass the name of the class to Class.forName(...).nextInstance(); but that is an error‑prone way to create instances. It also requires the class have a public no‑args constructor.
String className = "Instance" + "A";

[edit]Somebody pointed out I got the name of the method wrong. It should be newInstance().

2 days ago
Welcome to the Ranch

Afraid that doesn't help. There is no HTML5() method there. You are mistaken about the syntax for “inputs”, but there are no inputs there
3 days ago
Welcome to the Ranch

I would prefer a method with a loop, because it would be scalable.
3 days ago
. . . and?
The String expression produced by the + operator in line 7 isn't a compile time constant.
3 days ago
Please always tell us where such quotes come from, to avoid copyright problems, and so we can assess the sources. I am not convinced you have found a good source.

Erasure was used because otherwise generics would have broken old code; it generics had been introduced at the very beginning of Java®'s lifecycle, they would probaby have used reification.
No, type parameters are not replaced by anything in erasure; they are removed. An ArrayList wraps an Object[]. So the runtime form of any List is the same as it would be for a List<Object>. It is not possible to replace the Object[] by a T[], so all ArrayLists contain an Object[].
4 days ago
Welcome again ... and what will happen if your List includes 10, 11, 12, 9, 9, 8, 14, 15?
4 days ago