public void readArguments(String[]args ) {
String [] readArray = new String[ 10 ];
Scanner readscanner=new Scanner(System.in);
// read values from keyboard into array
System.out.println("Enter your arguments or type Exit to exit the loop");
for ( int i = 0 ; i < readArray.length ; i ++) {
if(readArray[i] =="Exit" ) break;
readArray[i] = readscanner.nextLine();
}
//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 {
System.out.println("More than 5 arguments passed");
}
}
betny 0 Newbie Poster
Aviras 5 Junior Poster in Training
JeffGrigg commented: Very helpful answer to beginner question. +4
betny 0 Newbie Poster
hfx642
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.