How to write action class in java

In fact, it's possible to have a lot of fun while programming in Java.

How to write action class in java

Immutability means read only, which means once you create Immutable object, you can't change it's state. How to make class Immutable?

To make any class immutable, you have to apply following steps 1. Make the class as final, so that no other classes can extend. Declare all the fields as private, so that no other classes can access directly.

Your Answer

Declare all the fields as final, and initialize those from constructor. Provide getter methods for the private fields, But make sure to return copy of the field, not the actual field.

Advantages Of Immutable Objects: One main advantage for using immutable objects is Thread Safety, because the values cannot ever change, they can be freely passed from thread to thread without ever needing locking. This means that, because there is no locking with synchronized blocks, there is no bottleneck where multiple threads need to wait for a single mutable value to be available.

Usually when you have a need to update the value in an immutable object, you make a new copy of the object with the updated value. Examples of Immutable classes 2.The Java Class Libraries, Volume 1:,,,,, (2nd Edition) [Patrick Chan, Doug Kramer, Rosanna Lee] on *FREE* shipping on qualifying offers.

Volume 1 is the definitive reference to the Java class libraries from the creators of the Java technology at Sun Microsystems. Section 1. Before you start About this tutorial This tutorial is a guide to help you become a Sun certified Java programmer. It is organized in the same way as the Sun Certified Java Programmer (SCJP) exam and provides a.

Struts 2 Action classes makes our life easier with handling the data mapping to action class bean properties or to another java bean internally.

It saves a lot of code that we used to write with Servlets.

how to write action class in java

Chapter Swing basics. Most programs that people use from day to day involve a graphical user interface, a term which is abbreviated as GUI and often pronounced're going to look at how to build a GUI using a Java library called Swing.

I'm creating an struts2 application which has a login page and another user details page.

how to write action class in java

There, i need to create only one action class. Because of that I'm unable to run the application by adding the field validations in both two pages to the The Action object is registered as an action listener on the component.

If the state of the Action changes, the component's state is updated to match the Action. For example, if you change the enabled status of the action, all components it's attached to change their enabled states to match the action.

ReentrantReadWriteLock (Java Platform SE 7 )