fred rosenberger

lowercase baba
Bartender
+ Follow
since Oct 02, 2003
fred likes ...
Chrome Java Linux
Forum Moderator
fred rosenberger currently moderates these forums:
St. Louis
Cows and Likes
Cows
Total received
50
In last 30 days
0
Total given
17
Likes
Total received
1633
Received in last 30 days
2
Total given
49
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by fred rosenberger

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.
13 hours 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...
2 days ago
remember than on a vanilla array, "length" is a method, not a parameter.  so you'd need

array.length();

not

array.length;
2 days ago
We have a FAQ on this exact topic found here.

but it boils down to this:

i=i++;

means:

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.
2 days 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.
5 days ago
question...why do you need the anchors?  if you start and end your expression with ".*", do those actually matter?
2 weeks 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?

2 weeks ago
I have lost count the number of times i've told people "An example is not a spec".  While it can certainly help, it is far from sufficient.

I think all CS programs should offer a class in spec writing. 
2 weeks ago
"leave the input for last" actually has a lot of sub-text as well.  That means that what you write now, with the hard-coded starting position, should be written in such a way that it doesn't matter how you get the input.  You should basically write your classes/methods so that they take some kind of starting position argument. 

That way, you can write the "get the input" to be a gui, to read a flat-file, to pull from a database, to listen on a socket...whatever.  Those would then all build the starting position parameter to look the same, so you could use any to get the input...

In other words, try and separate what can be separate.
2 weeks ago
there is a raging debate about whether the State I live in (Missouri) has a last syllable pronounced like "ee", or "uh".  Generally speaking, the more urban areas are "ee", and the more rural are "uh". 

There is a city near me spelled "Des Peres", but we pronouce it like "duh pear". 

"Gravois" road is pronounced "Gra-voy" (with the 'a' sound like "hat") .

"Spoede" road is called "spadey"

and "Creve Coeur" is pronounced to rhyme with "leave more". 
3 weeks ago
The best way to do it is according to your company's coding style guide.  Nothing is more frustrating than when someone starts going against the convention.  You never know what that might break...We have a lot of utilities that rely on things being done a certain way.  If someone were to start changing things in only some source files, there would be unintended consequences.
3 weeks ago
some folk here would even argue you should do it this way:

password.equals(s)

The reason being that you KNOW, without out a doubt, that "password" is not null.  If somehow your 's' variable doesn't get initialized, you can get a null pointer error by calling s.equals.
1 month ago
back up a moment...

do you want to INVEST, or do you want to SPECULATE?

Investing means you're in it for the long haul.  You invest in a retirement account.  Your money is going to sit in the account and grow for 10, 20, or even 30 years (or more, if you are smart and start early).

Speculating is buying/selling stocks in the hope of turning a quick profit. This has the potential for much greater returns, but also much greater losses.

Personally, I invest.  I put most of my money into an index fund - specifically one pegged to the S&P 500.  There's no real fund manager who's salary has to be covered. There are no decisions about when or where to move the money around. The fees are incredibly low.  And it just sits there and moves with the market. As i get older, I start shifting more of my money into bonds, which are safer but offer a lower yield. The closer I get to retirement, the less risk i can tolerate.
1 month ago
Simply saying "i'm stuck" gives us nothing.  We have no way to know what kind of help you need. 

Are you stuck downloading the JDK?  Can you write a hello, world program, compile, and run it? 

Are you getting compiler errors? Runtime errors?

Do you know what "negative Denary numbers" are?  do you know what Two's complement is?

You're problem could be any of these...or none.  HELP US HELP YOU. 
1 month ago
you've got some formatting issues with your post, but otherwise it's fine.  I think you have an extra code tag too early.  What I generally do is once I've pasted in my java code, highlight it, then click the "code" formatting button.

As to your issue...

You never want to us "==" to compare anything but primitives (ints, floats, etc).  you really need to use the .equals method...something like



This still may not work, since nextLine may also get the newline at the end...i'm not sure about that...someone may come along soon and correct me on that.
1 month ago