Well I'm still waiting to learn a bit more about your application. All you have told me is that you want to start it from "main". This tends to imply that it's not a
servlet or
applet based example you are looking for, as they don't have a "main". Please tell us more about what context you are thinking of applying this pattern in.
In the meanwhile, if you are more concerned about decoupling, consider this slightly more elaborate example:
I've tested it so I know it will compile. Save the code block as "Application.java", Compile it with "javac Application.java", and run it with "java Application".
At the prompt, you can type one of the following commands:
X :- to exit the calculatorA :- to add a new view. The controller can have as many views as you like.R followed by a number :- to remove the numbered view+ followed by a number :- to add the number to the stored value- followed by a number :- to subtract the number from the stored value= to refresh all the views try the following sequence, as an example
Does this offer any more help in understanding how MVC can help with decoupling?