What are the other Variables in Java and their uses with a sample syntax
In Java, variables are used to store values that can be manipulated and accessed throughout a program. There are different types of variables in Java, including primitive types and reference types. Here are some commonly used variables in Java with sample syntax:
- Primitive Types:
- int: Used to store whole numbers.
<span class="hljs-type">int</span> <span class="hljs-variable">myNumber</span> <span class="hljs-operator">=</span> <span class="hljs-number">42</span>;
 - double: Used to store floating-point numbers.
<span class="hljs-type">double</span> <span class="hljs-variable">myDecimal</span> <span class="hljs-operator">=</span> <span class="hljs-number">3.14</span>;
 - boolean: Used to store true/false values.
<span class="hljs-type">boolean</span> <span class="hljs-variable">isTrue</span> <span class="hljs-operator">=</span> <span class="hljs-literal">true</span>;
 - char: Used to store single characters.
<span class="hljs-type">char</span> <span class="hljs-variable">myChar</span> <span class="hljs-operator">=</span> <span class="hljs-string">'A'</span>;
 
 - int: Used to store whole numbers.
 - Reference Types:
- String: Used to store a sequence of characters.
<span class="hljs-type">String</span> <span class="hljs-variable">myString</span> <span class="hljs-operator">=</span> <span class="hljs-string">"Hello, World!"</span>;
 - Array: Used to store multiple values of the same type.
<span class="hljs-type">int</span>[] numbers = {<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>};
 - Object: Used to store instances of classes or custom objects.
<span class="hljs-type">MyClass</span> <span class="hljs-variable">myObject</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">MyClass</span>();
 - List: Used to store a collection of elements.
List<String> names = <span class="hljs-keyword">new</span> <span class="hljs-title class_">ArrayList</span><>();
names.add(<span class="hljs-string">"John"</span>);
names.add(<span class="hljs-string">"Jane"</span>);
 - Map: Used to store key-value pairs.
Map<String, Integer> scores = <span class="hljs-keyword">new</span> <span class="hljs-title class_">HashMap</span><>();
scores.put(<span class="hljs-string">"John"</span>, <span class="hljs-number">95</span>);
scores.put(<span class="hljs-string">"Jane"</span>, <span class="hljs-number">80</span>);
 
 - String: Used to store a sequence of characters.
 
These are just a few examples of variables in Java. The type of variable you choose depends on the kind of data you want to store and manipulate in your program.
