/*
* @author BChepkwony
* Created on 10 August 2011
*/
package com.jjpeople.mainmethod;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;
import java.util.Scanner;
import java.util.Arrays;
/**
* MainMethodExercise demonstrates how you can pass in arguments into the
* application.
*
* @author BChepkwony
* Created on 10 August 2011
*/
public class MainMethodExercise {
public Logger logger = Logger.getLogger( MainMethodExercise.class );
/**
*Read Arguments from run.bat file
*@param args An Array of Args is passed
*/
public void readArguments( readArray) {
String[] readArray;
String [] readArray = new String[ 9 ];
Scanner readscanner=new Scanner(System.in);
// read values from keyboard into array
System.out.println("Enter your arguments");
for ( int i = 0 ; i < readArray.length ; i ++) {
System.out.println("The Arguments you entered is"+ ( i + 1 ));
readArray[i] = readscanner.nextString();
//Determine if the number of Arguments is less or greater than 5
if(readArray.length<=4){
System.out.println("There are less than 5 arguments passed");
}
else if(readArray.length>=5){
System.out.println("More than 5 arguments passed");
}
}
}
/**
*Count in total the number of arguments read
*Use log4j to Print the results on the console
*/
// public int countArguments( String args[] ) {
//logger.debug( "In countArguments(..)" );
// for(int i=0; i < readArray.length; i++){
//System.out.println("The number of argments is:"+ readArray[i] );
//}
// for ( String argument : args ) {
//System.out.println( "argument = " + argument );
//}
// }
/**
* This is the starting execution point of the program.
*
* @param args the args are parameters passed into this java program from
* the command line. In this example parameters are being passed into
* this programme and the printed to the console.
*/
public static void main( String[] args ) {
MainMethodExercise mainMethodExercise=new MainMethodExercise();
mainMethodExercise.readArguments(readArray);
}
}
betny 0 Newbie Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
betny 0 Newbie Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
betny 0 Newbie Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
betny 0 Newbie Poster
JeffGrigg 170 Posting Whiz in Training
betny 0 Newbie Poster
stultuske 1,116 Posting Maven Featured Poster
betny 0 Newbie Poster
betny 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.