Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: a quick question . args argv.

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    5
    My Mood
    Amazed
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default a quick question . args argv.

    The code would be as such..
    import java.util.*;
    // Import for Scanner class
     
    public class test
    {
     
        public static void main(String[] args) 
    	{
     
            // TO DO code application logic here
     
            System.out.println("testing in progress::start");
     
    	if(args.length == 5)
    	// to test number of inputs
    	{	
    	System.out.println("correct number of inputs");
    		//testing for  input success.
    		if(	args[0].equals("hey") && args[1].equals("-e")		)
    		{	
    		System.out.println("testing in progress::current");
     
    		// Create Scanner object to take input from command prompt
    		//Scanner s=new Scanner(System.in); 
    		// Take input argv3 == key
     
    		String s = args[2];
     
    		// Initialize the variable count to 0
    		int count=0;
     
    		// Convert String st to char array
    		char[] c=s.toCharArray();
     
    		System.out.println(s);
     
    		// Loop till end of string
    		for(int i=0;i<s.length();i++)
     
    		//If character at index 'i' is not a space, then increment count
    		if(c[i]!=' ') count++;
     
    		//Print no.of chars other than spaces (to check space is 10 or smaller. :: yet tested)
    		System.out.println("No.of chars other than spaces are "+count);
     
    		}
    		else
    		{
    		System.out.println("testing :: error");
    		System.out.println(args[0]);
    		}
     
    	}
     
    	else
    	{
    	System.out.println("testing in progress::end");
    	}
     
    	}
     
     
     
    }
    Basically i am attempting to make use of values in argv, in string.
    currently trying to read out one input to verify data.. to code for input verification. e.g argv0 to compare a particular string input e.g that args counter should be more then 0 but not more then 10


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: a quick question . args argv.

    And what problems are you having? What's your question?

  3. The Following User Says Thank You to GregBrannon For This Useful Post:

    rzzz (January 11th, 2014)

  4. #3
    Junior Member
    Join Date
    Jan 2014
    Posts
    5
    My Mood
    Amazed
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: a quick question . args argv.

    Hi Greg,

    Apologies but it has been resolved.

    Was unable to extract args values.

Similar Threads

  1. quick question
    By jco69 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: April 19th, 2013, 09:38 AM
  2. Quick question
    By l1nk3 in forum Java Theory & Questions
    Replies: 1
    Last Post: February 24th, 2012, 02:02 PM
  3. quick question, please HELP!
    By Nemus in forum What's Wrong With My Code?
    Replies: 14
    Last Post: September 29th, 2011, 01:23 PM
  4. Quick Question
    By sird00dguyman in forum Java Theory & Questions
    Replies: 2
    Last Post: August 4th, 2011, 06:14 PM
  5. Hi, quick question
    By curras in forum Member Introductions
    Replies: 1
    Last Post: March 21st, 2011, 03:21 PM