This week's book giveaway is in the Python forum.
We're giving away four copies of Python Continuous Integration and Delivery and have Moritz Lenz on-line!
See this thread for details.
Win a copy of Python Continuous Integration and Delivery this week in the Python forum!

Carey Brown

Bartender
+ Follow
since Nov 19, 2001
Carey likes ...
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
Forum Moderator
Carey Brown currently moderates these forums:
Cows and Likes
Cows
Total received
56
In last 30 days
1
Total given
2
Likes
Total received
1018
Received in last 30 days
28
Total given
126
Given in last 30 days
2
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Carey Brown

Campbell Ritchie wrote:There is a use for an empty else: it produces a compiler error if you put the dreaded extra semicolon after if (...);


Interesting point but:
  • Compilers should give an error or at least a warning in such cases.
  • Code would look like hell if you did this for each and every if().


  • [edit] IMHO
    3 hours ago

    There are two approaches to solving your problem and you're incorrectly mashing them together. One way would be to increment your loop by 1 and then use the modulus operator. The other would be for the loop to start at 5 and increment by 5 and forget the modulus all together.

    Note that your 'else { }', because it is empty, isn't needed at all.
    10 hours ago
    If they are in sorted order, or you are able to sort them yourself, then you can create a variable that tracks what the previous string was, and IF it's the same as your current string, then increment a counter, ELSE print the previous string with the count.

    If you can't sort the list or you want to use Collection's then a Map<String,Integer> would work where the Integer is the count of instances of String.
    10 hours ago

    Rob Spoor wrote:You can just skip everything until Java 17, because that will be the next LTS version. Java 12 will be EOL in September already. Java 11 will be the LTS version until 2021.

    "LTS"? "EOL"?
    1 day ago
    Online API Documentation

    If anyone finds out where you can download this so that you have a local copy please let us know. I tried but couldn't find it.
    1 day ago
    I don't know if this will require an Eclipse (or other IDE) upgrade.
    1 day ago
    The only obvious new feature that I'm aware of (I'm sure there's more) is new switch() syntax enhancements.
    1 day ago
    In addition to your total+=, put a print statement of 'i' and 'j', then you'll see.
    3 days ago
    Here's a sample program for playing with command line behavior.

    3 days ago
    Ah, the joys of command line arguments!

    Before your java code gets the "three" command line arguments they are first processed by your operating system's command "shell" program. For Windows, this is "cmd.exe". "cmd.exe" is run from inside some directory (aka "folder") on your machine, this is your "current working directory".  "cmd.exe" does some neat tricks when parsing a command line, it separates arguments by white space, and it attempts to match arguments to file or folder names in the current directory using wild card matching. An asterisk (*) is such a wild card.

    So if you enter: 2 * 3
    then cmde.exe will pass: 2 file1 file2 file3 3
    to Java.

    Stick some print statements in your code and you will see this in action.

    In your case the simplest thing to do would be to use a lower case 'x' for multiplication instead of the asterisk.
    3 days ago
    You can't compare a char to a String.
    4 days ago
    Suggest:
    4 days ago
    You don't need a loop at all because you are explicitly declaring the array index value. E.g. "args[0]".
    4 days ago