Results 1 to 2 of 2
- 04-23-2010, 12:53 PM #1
Member
- Join Date
- Apr 2010
- Posts
- 1
- Rep Power
- 0
is this correct not supposed to edit the printValues method
is what i wrote correctJava Code:/* * Fill in the class method main of the class ex3 with code that checks * to see if exactly one command-line argument is supplied: * -if more than one arguments are supplied, the program prints the string "Wrong input" directly from the main method * -if exactly one argument is suppled, the program prints the argument * args[0] by calling, from the class method main, the instance method printValues(s) * NOTICE that in the one argument case, you are not allowed to print the argument directly from the main method by using System.out.println * (or print). * nOTICE that in this case you need to call an instance method (i.e. printValue(s)) from a static class method(i.e. main). you are not allowed to create any new methods * all the code for this exercise must be inside the class method main * * for example. * if you run the program with "one" on the screen * if you run the program with "one two three" as command-line arguments, it should print "Wrong input on the screen" */ public class Ex3{ public void printValues(String s){ System.out.println(s); } public static void main(String args[]){ for(int i=0; i>args.length;i++) if(!args[i++].isEmpty()){ System.out.println("Wrong input"); } else{ Ex3 a = new Ex3(); a.printValues(args[0]); } } }
- 04-23-2010, 05:56 PM #2
Senior Member
- Join Date
- Mar 2010
- Posts
- 266
- Rep Power
- 4
Similar Threads
-
JButton doesn't disappear when it is supposed to?
By ecliptical in forum New To JavaReplies: 4Last Post: 01-25-2010, 12:41 AM -
Is this the correct Output?
By Teny in forum New To JavaReplies: 17Last Post: 04-13-2009, 12:52 PM -
Help interpreting what a class is supposed to do
By bornwithnoname in forum New To JavaReplies: 2Last Post: 11-20-2008, 12:19 AM -
Is my Pseudocode correct?
By Clemenza1983 in forum New To JavaReplies: 0Last Post: 01-29-2008, 04:07 AM -
To correct forum
By Jman in forum IntroductionsReplies: 3Last Post: 01-18-2008, 02:33 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks