Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!

Carey Brown

Saloon Keeper
+ Follow
since Nov 19, 2001
Carey likes ...
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
Forum Moderator
Carey Brown currently moderates these forums:
Colorado, USA
Cows and Likes
Cows
Total received
65
In last 30 days
0
Total given
4
Likes
Total received
1327
Received in last 30 days
6
Total given
184
Given in last 30 days
1
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Carey Brown

Can you use arrays? (Do you know how to use arrays?)
1 day ago
Do you know how to create a class? Do you know how to use arrays? Ideally you'd have a Racer class with name and time fields. Then your application would have an array of five Racers.

Note that time is minutes in floating point format, therefore you can't use an int, you must use a double.
1 day ago
1 day ago
You get a file name from chooser and look to see if exists but that is not the file name you actually use, that one has ".xml" appended to it.

Also, you have
2 days ago
As long as you're not chaning the signature of a method you can change it's behavior to some degree as long as you honor the intent of the method. This "should" not cause other code to break, but it could, depending on the changes you make. A common setter change is to add validation to the value being passed in. This should not break code that calls it and any code that was passing bad values in previously should have been considered broken, but it just wasn't being dealt with.
1 week ago
Congratulations. Please post your working code so that others may learn from it.
1 week ago

Campbell Ritchie wrote:Well, actually, the specification said array, so Lists oughtn't to count.


You're right. My bad.

P.S. It also says "function", so...
2 weeks ago
Suhaas, as already mentioned, you have messed up the logic at line 55.

Some points to simplify your code:
  • 'sum' can be a local variable, it doesn't need to be a parameter.
  • You can use an enhanced for() loop: for( Object o : array ), this eliminates the need for get(i).
  • You can start depth at 0 outside of productSum() and then increment it as soon as you get inside productSum(), in this way the depth is '1' the first time through. Of course doing this eliminates the need for the '+1' in the recursive call.
  • 2 weeks ago
    Piet, I think that all we care about are Lists and whether they are ArrayLists or come from asList() doesn't matter. I cut and pasted this into Eclipse and it works fine.
    2 weeks ago
    This form of for() loop always has three components separated by exactly two semi-colons, even if they are empty:
    2 weeks ago

    and the poor beginner is thrown into the deep end of the swamp.


    And the poor developer trying to distribute a simple app.
    2 weeks ago
    On Wlindows there is another gotcha, you have to place %JAVA_HOME%\bin first on the PATH because Oracle was embedding an older link to Java in C:\Windows which normally comes first or early on.
    2 weeks ago
    Most people on this site will not follow an unknown link. Could you please cut and paste the code into a post and UseCodeTags (<-link).
    2 weeks ago
    '5' is the quantity of nodes which is also the quantity of lines to read.

    Could you show us a loop that would read lines as Strings()?

    You can use line.split(",") as the first step to parsing the line.
    2 weeks ago