Is it possible to access the variables of a object the same way you can in JS.
For example:
import java.util.*;
class Dice{
public String [] side;
public String name;
public Dice (String n, String ... a){
name = n;
side = a;
}
//Setter and Getter side
public String getSide(){
return side;
}
public void setSide(String s){
side = n;
}
}
The array is initialized in main like so:
Dice easy = new Dice("Green:","Brain","Brain","Brain","Foot Print","Foot Print","Shotgun");
It has a name "Green".
The rest of the objects Strings are stored inside a String array.
To access the array in JS you can:
Dice.side[1];
Can we access them in Java like this, I am trying to access the array in main()?
String theStringInArray = Dice.side[1];
System.out.println(theStringInArray);
The result should print "Brain" in this example.
(This is only for myself and to gain practice I have been reading about ArrayLists but only using arrays in this example :)