The MVC pattern represents the Model-View-Controller mode. This mode is used for layered development of applications.
- Model - The model represents an object that accesses data or a JAVA POJO. It can also be logical to update the controller as the data changes.
- View - The view represents the visualization of the data contained in the model.
- Controller - The controller acts on the model and view. It controls the flow of data to the model object and updates the view as the data changes. It separates the view from the model
We will create an Student object as a model. StudentView is a view class that outputs student details to the console. StudentController is the controller class responsible for storing data into the Student object. And update the view StudentView accordingly.
MVCPatternDemo, our demo class uses StudentController to demonstrate the use of MVC patterns.
Create a model.
Create a view.
Create a controller.
Use the StudentController method to demonstrate the use of the MVC design pattern.
Executing the program, outputting results:
Student: Name: Robert Roll No: 10 Student: Name: John Roll No: 10