fred rosenberger

lowercase baba
+ Follow
since Oct 02, 2003
fred likes ...
Chrome Java Linux
Forum Moderator
fred rosenberger currently moderates these forums:
St. Louis
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 Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by fred rosenberger

if you don't have much experience as you say, here's the best advice i can give you.

delete most of this code.

I've been a professional coder for 20 years. I NEVER write more than 2-3 lines before compiling.  Then i test that code. and then test it some more.  When I'm sure it is correct, i'll write 2-3 more, and repeat.

You've got what...a hundred lines?  it's going to be almost impossible to find all the errors.  So, delete it all. Start over.  Sure, you can also just comment out most of it.  Start with nothing but your main method, and 1-2 lines. something like:

See if that works. Maybe stick in a "Sytem.out.println("File name is " + fileName")

assuming it does, take out the S.o.p, and add another line or two...maybe your while loop, and instead of "processOneLine()", just print the one line.  Get that to work. Once it does, then maybe add the next processOneLine, but have it only print the line. In other words, make sure you can pass in the line to the method. Once that works, start adding the part to process it.

if you only add 2-3 lines at a time, it's easy to know where the error is.

it sounds much more tedious, but it truly will save you time, effort, and headaches in the long run.

1 day ago
Dave asked if you have a "CLASSPATH" variable - that is completely different than a "PATH" variable...
4 days ago
Here's a tip for next time...

don't be afraid to use lots of temporary "System.out.println" statements. Print the value of i. print character c. print "i'm in the If side". Print "i'm in the else side" print "i'm replacing character <whatever> with <whatever>"...

use that to figure out where the code is doing something different than what you expect. 

If you find something is working correctly, take those print statements out, and then stick in more near where the issue is.
1 week ago
Are you asking how to set the value of a string based on the input?  So you ask the user "Choose a string". Then if they choose option 'a', you want hte string to be "Hey", and if they choose 'b' you want it to be "Man"?
1 week ago

Rocky Rocha wrote:Well, first of all I would draw rooms, both square and round.

There is just a LOT buried in that simple statement. How do you decide where to draw them? How do you decide which room is square, and which is round? How big should each be? How many? How far apart?

and there are probably a hundred other questions i've not even thought of.
2 weeks ago
I would say the two examples aren't equivalent at all. in the first, the called method returns a new string, and your variable is set to point to that returned string.  In the second, you don't return anything.  Here are you examples boiled down a bit.

example 1:

example 2:
2 weeks ago
without extracting at all?  I think you have to extract them to some extent, but you don't have to extract them to disk.  The -O flag should extract them to stdout, which you could then pipe to your something like

tar xvf <your.tar.file> -O | zgrep <yourpattern>
2 weeks ago
I think that should probably be:

3 weeks ago
There is a house.  The bedroom is blue.
There is a piece of paper, with the address of the house written on it.
A copy of that piece of paper is handed  to you.
You go to that address, and paint that bedroom green.
You then erase the address on your piece of paper.
I then go to the address on the first piece of paper, look in the bedroom, and state what color it is.  It is green.

That's pretty much what is happening in your code.  t1 has effectively the address of the object. When you pass it into your method, you pass a copy of the address.  in your print method, you use that address to update the actual object, then erase the local copy of the address. the actual object has been changed.

so when you are then back in your main method, and you go to what t1 points to, that underlying object has changed.
3 weeks ago

Norm Radder wrote:fred Please check your post.
.length is a field for a vanilla array
length() is a method for a class

your'e saying i have it backwards? 

dang it.

that's what happens when you don't use a language for 5-10 years...everything you once knew gets all jumbled up...
3 weeks ago
remember than on a vanilla array, "length" is a method, not a parameter.  so you'd need



3 weeks ago
We have a FAQ on this exact topic found here.

but it boils down to this:



evaluate the expression "i".  it is 0.
increment i.  It is now 1.
now assign what we evaluated earlier to what is on the left side of the "=".  that was 0, so assign 0 to i, erasing whatever was there.
3 weeks ago
side note - there aren't really any such things as "java regular expressions".  There are "regular expressions", and then a way to use them in java.  i have written regular expressions and used them in java, perl, tcl, and even shell scripts.

Sometimes, it's best to step back a bit, and first figure out what the regular expression you want is, and only then try and figure out how to implement it in java.
1 month ago
question...why do you need the anchors?  if you start and end your expression with ".*", do those actually matter?
1 month ago
I wouldn't do it with a single regular expression.  I'd break it up into pieces...Have something that finds the position at the end of the second word. have something that finds the first time value after that point. then have something that finds everything in between.

While writing a single regular expression may look cool, in six months will you remember everything about it?  What will you do if your requirements change?  What will the next person who comes along be able to figure out about your regex?

1 month ago