I have a problem regarding that my program prints objects instead of string.
I have a class which is called constants.java
in it there is the following:
public interface constants
{
String[] FIELD_NAMES =
{
"test1", "test2"
};
}
In my main class i try to print these fields.
public void fillFields() {
for (int i = 0; i < plate.length; i++) {
// Det her er noget quick-and-dirty-fusk:
switch (i + 1) {
// Andre felter:
case 1:
plate[i] = new OtherField(Constants.FIELD_NAMES[i], i + 1);
break;
default:
plate[i] = new OtherField(Constants.FIELD_NAMES[i], i + 1);
}
and this is the main String print out function:
public static void main(String[] args)
{
System.out.println(plate[current.getPos()]);)
}
the getPos is a number generator(lets say between 1 and 2) and the current is a player index, and i have checked it, and it is working. but when i fx. land on "otherField
" plate, i get an output like: otherfield@1b6d3586
I think its because i am printing the object instead of the string, but how can i solve this?