Results 1 to 2 of 2
  1. #1
    Vinx is offline Member
    Join Date
    May 2012
    Location
    USA
    Posts
    38
    Rep Power
    0

    Default Example Count From Array Snippet

    Simple script I made to count everything in a array, and to display it with proper grammar. I gave decent commentary, should sum everything up.

    Java Code:
    /**
     * 
     */
    
    /**
     * @author Vinx @ http://www.java-forums.org
     *
     */
    public class Program {
    
    	/**
    	 * @param args
    	 */
    	public static void main(String[] args) {
    	    String[] getShells = {"http://127.0.0.1/shell.php", "http://127.0.0.1/shell.php", "http://127.0.0.1/shell.php"}; // List of shells
    	    String shellWord = "shells"; // Define shellword string
    	    String areIs = "are"; // areIS, defined string to be changed for proper grammar in sentence.
    	    int shellCount = (int) getShells.length; // Get the number of shells as integer
    	    if (shellCount == 1) { // If shellCount is 1, then do the following measures:
    	        shellWord = "shell"; // Say shell instead of shells
    	        areIs = "is"; // Say is instead of are
    	    }
    	    System.out.println("There " + areIs + " " + shellCount + " " + shellWord); // Say the final sentence to console :D
    	    
    	
    
    	}
    
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: Example Count From Array Snippet

    Moved from Java Example --> Array. Please read the note in the forums listing:
    Learn Java programming with our Java tutorials and tips. Attention: Only forum staff can post to these forums!
    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Duplicate count in array
    By louboulos in forum New To Java
    Replies: 2
    Last Post: 05-10-2012, 05:37 PM
  2. How to count records WITHOUT an array?
    By teekei in forum New To Java
    Replies: 17
    Last Post: 07-25-2011, 12:42 PM
  3. How do I count empty spaces in a byte array?
    By nessa203 in forum New To Java
    Replies: 13
    Last Post: 01-11-2010, 05:46 PM
  4. i can do count, but having problem with array
    By judy318 in forum New To Java
    Replies: 4
    Last Post: 10-29-2009, 09:23 PM
  5. Array count number Occurances
    By gwithey in forum New To Java
    Replies: 2
    Last Post: 04-17-2009, 08:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •