# Making strings into variables in Java.

**URL:** https://discussions.unity.com/t/making-strings-into-variables-in-java/602911
**Category:** Scripting
**Tags:** Scripting
**Created:** [October 26, 2015, 6:44am UTC](https://discussions.unity.com/t/making-strings-into-variables-in-java/602911 "2015-10-26T06:44:13Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![cristo](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/cristo/32/125837_2.png) [@cristo](https://discussions.unity.com/u/cristo)
#### Post date: [October 26, 2015, 6:44am UTC](https://discussions.unity.com/t/making-strings-into-variables-in-java/602911/1 "2015-10-26T06:44:13Z")

</div>

Hi in the below Java code, I want to be able to declare what the variables in the strings are, like how you do the following in C#

```csharp
public void Red()
    {

        gameObject.GetComponent<Renderer>().material.color = Color.red;
}

```

//-------------------------------------- Distance 35- 25+  
if (Distance \<= 35 && Distance \> 25 && !Once2) {  
State = States[Random.Range(0,3)];  
Move = Moves[Random.Range(0,3)];  
Once1 = false;  
Once2 = true;  
Once3 = false;  
}  
//-------------------------------------- Distance 25-

}  
}[/code]

---

<div class="post-metadata">

### Author: ![lordofduct](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/lordofduct/32/890751_2.png) [@lordofduct](https://discussions.unity.com/u/lordofduct)
#### Post date: [October 26, 2015, 7:17am UTC](https://discussions.unity.com/t/making-strings-into-variables-in-java/602911/2 "2015-10-26T07:17:39Z")

</div>

1. it’s javaSCRIPT… and really even that is a misnomer. It’s ‘unityscript’, a dialect based on that of javascript.

2. that C# code doesn’t use strings for anything, so… I’m not sure what you’re attempting to emulate from that C# code.
