Hmmm. This seems like it's an important exam to you ... how much is it worth
First off I hadn't actually ran that EchoTest class through my compiler, something you really should do after every few lines of code. If you run the class you'll get two compile time errors. Here's the fix
public class EchoTest
{
public
void echo(String name)
{
System.out.println("You said " + name );
}
public static void main(String []args)
{
for(int i = 0; i < args.length; i++)
{
EchoTest
echotest = new EchoTest();
echotest.echo( args[i] );
}
}
}
There's a little bit more going on in that second problem so I won't do it all for you but here's the main structure
public class NumberFormatter
{
public static String format(int number, int width)
{
//This is just the skeleton of the method. Try working out the logic
String answer = "";
return answer;
}
public static void main(String []args)
{
NumberFormatter nf = new NumberFormatter();
int foo = Integer.parseInt(args[0]);
int bar = Integer.parseInt(args[1]);
NumberFormatter.format( foo, bar);
}
}
I'm leaving the logic in the 'format' function for you to attempt. If you get stuck then let me know but at least give it a try for for your own benefit. Look into the formatting classes in the API for some help.
The scanner library package was added in Java 5 AFAIK. It's a cleaner way of getting command line input. Not sure if your tutor would have wanted you using it though as it's a bit too easy.
Have a read through this
http://stackoverflow.com/questions/5...anner-nextline
It has some good examples.
Edit: If the question is asking specifically for calls to static methods then you should look into what that means.
http://stackoverflow.com/questions/2...static-methods
http://stackoverflow.com/questions/1...method-in-java