Paul Witten

Ranch Hand
+ Follow
since Oct 10, 2012
Merit badge: grant badges
For More
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 Paul Witten

Mike Simmons wrote:This is probably unnecessary though. Why do you feel you need a count? Are you aware of the ordinal() instance method and values() class method that any enum class will have? You should be able to get what you want from either ordinal() or values().length.

Mike, my interest in the "count" thing was purely pedantic (I am not the OP), and as I have had little exposure to enum I wasn't even aware of the methods you mentioned.

But I do see that a field can persist exactly the same way as a class, so that "duh" moment has passed.
10 years ago

Rob Spoor wrote:All enum constants are created immediately when the class is loaded. So when you call w.RAINY (which should be Weather.RAINY), the Weather class is loaded and both RAINY and Sunny are created. Only then will w.RAINY.count and w.Sunny.count be evaluated.

I can see how the count var gets set to 1 on each pass of the enum constructor, Rob, but how does it persist after control leaves the enum and passes to main()? I can't even see the enum "instance" (if that is the right concept) in the debugger, let alone the count value.

Also, I see no way to set a useful counter in an enum as you can't reference a static field from the constructor.

10 years ago

Ed Dablin wrote:Fred, I think you are right. I think it is easier to learn using javac.exe and java.exe with, say, Notepass++ or Textwrangler, in the Command/Terminal window environment. Others may think otherwise....

Wait until you want to create a multi-package project (classes/jars found in separate paths) without an IDE. It's one of those things you have to savor at the moment. :-D You'll be begging for an IDE after that. Har. But it's a great learning experience to create a project like that. You will get a much greater understanding of what goes on.

But for refactoring and debugging, well, no comparison to the IDE. There is a reason why the IDE is considered a productivity tool. Maybe it's not a great learning tool, but it's a great productivity tool on the job. If somebody tells you to refactor a package you are far less likely to break the build. That means your palms don't sweat quite as much when you submit the new source files. Yes, sleeping well at night does count.
10 years ago

Paul Clapham wrote: It took me most of the day to find that hard-coded entry (which of course I had forgotten about) and remove it.

Problems appear a lot simpler in the rear view mirror (than they do real-time), hehehe.
10 years ago

Andy Jack wrote:Can you also give me the source of this information - like maybe a book or a well known website ?

You're poking into the architecture of the machine/processor now. Of course there are many differences between various platforms. To wit:

Every processor or processor family has its own machine code instruction set. Instructions are patterns of bits that by physical design correspond to different commands to the machine. The instruction set is thus specific to a class of processors using (much) the same architecture. Successor or derivative processor designs often include all the instructions of a predecessor and may add additional instructions.


Just google "machine code platform" and you will get all the hits you need, but it will be very arcane and not at all related to the high level languages we use. So it's not so much OS dependent as platform architecture dependent (which registers are at which addresses and how to talk to them, etc.)

10 years ago

Yahya Elyasse wrote:i tried the c# regex without change but it doesn't work. i mean i tried this one :

Please try a Java regex. That is what I meant by "what did you try?" It's pretty easy to find with google and you need to at least try something and get some result before asking somebody to do the work for you.

10 years ago

Yahya Elyasse wrote:it should match expressions of the form :

Righto, so what did you try (meaning the regex you've tried) and what was the result?
10 years ago

Yahya Elyasse wrote:hello,
what is the java equivalent of the C# regex :

Can you post what you got when you tried? It's doubtful anybody is going to do all the heavy lifting for you.
10 years ago

Tim Holloway wrote:I'd just slap a "System.out.println" in the move() method to print a log of its movements, compare the output to expected actions, and THEN use the debugger (if you need to) to see where/how it's going wrong.

Debugger probably not even necessary if he follows your sound advice. In fact, once you get used to using println() you begin to sniff where the problems are with your intuition better. If the output is wrong but the cause is still not obvious then the debugger may be necessary, but right now he could advance his cause considerably with println().

Also, I seem to remember a debugger problem that prevented the F-Keys from driving it on certain (Windows probably) versions of a certain platform, or on a certain brand of box, etc. The fix was easy - use the mouse instead of the F-Keys.
10 years ago

Jack Wool wrote:I have no idea why or what is going wrong

Just my 2 cents worth but you should consider stepping through the code in the debugger, and finding out exactly where it's failing. Then report back with a line number and values that you found wrong.

Otherwise, yeh, it's still very vague just what is going wrong. The debugger will show you var values at each step along the way. At some step you will notice it doing something you didn't expect or don't like. That's what you need to focus on. Then you'll be able to describe the problem in a way that will help focus on the right area.

Hey, that debugger is a wonderful tool. Don't ignore it. It's there to slow the world down and show you what the flow of control is and what values exist and go out of existence and when/where. Take advantage.
10 years ago

abhishek singhania wrote:Notice the effect of not placing the semicolon <;> at the end of servlet-api.jar.

Good catch! I have tried using semi-colon outside of the quotation marks. That is one of those Windows platform "gotchas" that you never see on Nix boxes.
10 years ago

Campbell Ritchie wrote: Of course, it could then take several minutes to compile a 50‑line class

All joking aside and all trivial code aside, the Big World does have to build systems such as Weblogic Server which already takes a couple of hours on a good box. It's unimaginable how that logic overhead would affect large projects. It might make them unbuildable in our lifetimes. I suppose that's good job security. Or maybe the opposite. "OK, we kicked off the build. You're now laid off because by the time the build is done you'll be 80 years old."

10 years ago

Campbell Ritchie wrote:.... once we know you have handed in your version.

You guys are tough. A nice little student can't even steal intellectual labor from you.
10 years ago

Campbell Ritchie wrote:So how did you do it?

He has hidden the details of implementation from you.
10 years ago

Ulf Dittmer wrote:"Not smart enough for this task" is the same as "too stupid for this task", isn't it?

I call it too smart to get involved.
10 years ago