Question: Can i use variable charity from th:each in another block of code. For example

```
 <select class="select-field">
    <option th:each="charity : ${charities}" th:value="${charity.id}" th:text="${charity.name}"></option>
 </select>

<div>
   <p th:text="${'You selected '+ charity.name}">
<div>

```

Answer: 
This line,

```
private static SingleTonClass obj=null;

```

declares a **static** variable of same class type `SingleTonClass`.

This above declaration is the standard method for implementing singleton classes as this static variable is the ONLY variable that will reference to just one object of Singleton class, that we will allow for creation and at the same time we declare the constructor as `private` so no other class can create the object of this class using `new` operator.

And this line,

```
public static SingleTonClass objectCreationMethod()

```

is another link to creation of Singleton class, where this method controls the creation and retrieval of the Singleton class's object.

Like I said above, constructor for Singleton class is made as private, so now we need some way to create or retrieve the Singleton class object and this method exactly does that. It is usually also declared as `getInstance()` is implemented as `public static`. Why public static, so that object of this Singleton class can be accessed by `Classname.getInstance()` and for your class it would be `SingleTonClass.objectCreationMethod()`

Hope this clarifies.
```
 private static SingleTonClass obj=null;

```

It is the SingleTonClass object and as you can see it is private so you cant modify the value, normally you would do 

```
SingleTonClass obj = new SingleTonClass();

```

to create and object but in this case the constructor method must be private in this way you cannot create an object of this Class at all, the only way is through this method

```
public static SingleTonClass objectCreationMethod()

```

Are static because you cannot do `SingleTonClass obj = new SingleTonClass();`
You can access on this simple way 

```
SingleTonClass myobject= SingleTonClass.objectCreationMethod();

```