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
1639
Received in last 30 days
3
Total given
49
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by fred rosenberger

Campbell Ritchie wrote:That means you would have to find an insertion point with binary search...


not technically true.  you will have to find an insertion point, yes, but you don't have to use a binary search. 
6 days ago
But what went wrong?  the sentence "it doesn't work" could mean any of about a thousand things...tell the details. be specific.  help us help you.
6 days ago
You say you declared it.  But that simply means you've told java "i'm going to have a thing called 'statement', and it will be of <whatever> type".

but if you've not initialized it, you've not actually created the object it refers to.  somewhere, you'd need to have a line like



1 week ago
I think all that's wrong.  We shouldn't start by teaching control structures OR object.  We should start by teaching them how to analyze a problem, and think about what's needed.  Pick some basic task, like a clock.  IMHO, we should begin with talking about how you need to display things, update things, and represent them internally. While these things are connected, they are in many ways separate.

We should talk about things like <how you get the input data> is separate from <what you do with it>.  For example, it doesn't matter how i get someone's name - from a database, from a file, from user input - but once I have it, i can pass it into a method to do something with it. 

We should talk about thinking through the flow of a program - first you do A, then B, then C, then maybe, depending on input, go back to A again...which would THEN lead to loops and control structures.  I think you could almost have an entire semester where you talk about analysis and theory, without ever writing a single line of any actual language code.
2 weeks ago
I generally paste this into every crontab file on every box i can:
# Use the hash sign to prefix a comment
# +---------------- minute (0 - 59)
# |  +------------- hour (0 - 23)
# |  |  +---------- day of month (1 - 31)
# |  |  |  +------- month (1 - 12)
# |  |  |  |  +---- day of week (0 - 7) (Sunday=0 or 7)
# |  |  |  |  |
# *  *  *  *  *  command to be executed


So without being more specific, i'm not sure what kind of help you need.  Can you elaborate?
3 weeks ago
you called the method like this:



but your method is defined as



Where exactly do you expect that "15" to go?

then, as Norm said, even if you had that fixed, you'd get strange results.  because "15" is an integer type, and "100" is an integer type, java will do integer division.  15/100 in integer division is 0. 
You probably want something like "giveDiscount/100.0"
3 weeks ago

Liutauras Vilda wrote:Barman: You need to buy a drink first. No spaces, all lowercase.


so really, the barman said "youneedtobuyadrinkfirst"
1 month ago
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.

fbr
1 month ago
Dave asked if you have a "CLASSPATH" variable - that is completely different than a "PATH" variable...
1 month 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 month 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 month 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.
1 month 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:
1 month 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 zgrep...so something like


tar xvf <your.tar.file> -O | zgrep <yourpattern>
1 month ago