I guess your intention with my ESP (joke) that A Class that returns a String which is randomly chosen from an array of Strings (which are names of chemical elements). If so, below is a possible implement.
Elements.java:
// The Class name of Java starts with upper case as normal
public class Elements {
// There is no need of this field value.
// public static String element_answer = "";
public String[] elements = new String[118];
// You need a random object
private Random random = new Random();
// Inside Constructor you can instantiate Strings in the Array
public Elements() {
// Array number starts from '0'.
// This is quite basic knowledge.
elements[0] = "Hydrogen";
elements[1] = "Helium";
elements[2] = "Lithium";
elements[3] = "Beryllium";
elements[4] = "Boron";
(...)
elements[117] = "Ununoctium";
// So array number starts from '0'
// that the last number is [array length] - 1
}
// You need to define a method.
// This is basic idea for Java Programmers!
public String getElementRandom() {
return elements[random.nextInt(elements.length)];
}
}
Usage inside your Activity
(or somewhere) is:
// Declare at field
Elements elements = new Elements();
(...)
// somewhere you want to use
p1_button1.setText(elements.getElementRandom());