---
title: "Can anybody say my below code is a variable, function or something else"  
description: "Can anybody say my below code is a variable, function or something else"  
author: "Madam Walker"  
published: 2013-10-14  
updated: 2013-10-14  
canonical: https://www.mindstick.com/forum/1654/can-anybody-say-my-below-code-is-a-variable-function-or-something-else  
category: "java"  
tags: ["java"]  
reading_time: 2 minutes  

---

# Can anybody say my below code is a variable, function or something else

I was going through some [application](https://www.mindstick.com/articles/12824/calculator-application-in-android)'s [source code](https://www.mindstick.com/forum/33476/pls-send-me-source-code-for-changing-passward-in-asp-dot-net-i-tried-so-much-from-google-but-its-not-workining) and I came across this piece of code and I am not able to understand what this is.

```
public enum XStreamUserType {
MES_CONFIG_XSTREAM(MESConstants.MES_CONFIG_XSTREAM_USER, "MES_CONFIG_XSTREAM_USER",    new XStream());
private int userTypeId;
private String userType;
private XStream xStream;
private XStreamUserType(int userTypeId, String userType, XStream xStream) {
    this.userTypeId = userTypeId;
    this.userType = userType;
    this.xStream = xStream;
    switch (this.userTypeId) {
    case MESConstants.MES_CONFIG_XSTREAM_USER:
        loadConfigReader();
        break;
    default:
    }
}
```

\

What does this line [mean](https://yourviews.mindstick.com/view/80768/what-does-real-minority-mean)?

```
MES_CONFIG_XSTREAM(MESConstants.MES_CONFIG_XSTREAM_USER, "MES_CONFIG_XSTREAM_USER",    new XStream());
```

## Replies

### Reply by Anonymous User

In java enum can also have instance variables and constructors like a class.

Here enum **XStreamUserType** has three instance variables

\

```
private int userTypeId;
private String userType;
private XStream xStream;
```

\

while

```
private XStreamUserType(int userTypeId, String userType, XStream xStream) {
    this.userTypeId = userTypeId;
    this.userType = userType;
    this.xStream = xStream;
    switch (this.userTypeId) {
    case MESConstants.MES_CONFIG_XSTREAM_USER:
        loadConfigReader();
        break;
    default:
    }
}
```

\

is constructor.\

MES_CONFIG_XSTREAM is enum variable(can be interpreted as object of a class), initialized as

ES_CONFIG_XSTREAM(MESConstants.MES_CONFIG_XSTREAM_USER, "MES_CONFIG_XSTREAM_USER", new XStream()); with values to its instance variables(as a constructor call).


---

Original Source: https://www.mindstick.com/forum/1654/can-anybody-say-my-below-code-is-a-variable-function-or-something-else

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
