I have a string array selectCancel
with setter and getter methods, which is a checkbox in my form. I am trying to get the checked values and I am getting the above result when I print.
I tried the Arrays.toString()
method but it still prints the same.
I then did the following:
String checked = Arrays.toString(Employee.getSelectCancel());
I also tried with the Arrays.asList()
and Arrays.copyOf()
So, how do I read this string?
Ljava.lang.String;@
is returned where you used string arrays as strings. Employee.getSelectCancel()
does not seem to return a String[]
[
stands for single dimension array
Ljava.lang.String
stands for the string class (L followed by class/interface name)
Few Examples:
Class.forName("[D")
-> Array of primitive doubleClass.forName("[[Ljava.lang.String")
-> Two dimensional array of strings.List of notations:
Element Type : Notation
boolean : Z
byte : B
char : C
class or interface : Lclassname
double : D
float : F
int : I
long : J
short : S
According to the Java Virtual Machine Specification (Java SE 8), JVM ยง4.3.2. Field Descriptors:
FieldType term | Type | Interpretation -------------- | --------- | -------------- L ClassName ; | reference | an instance of class ClassName [ | reference | one array dimension ... | ... | ...
the expression [Ljava.lang.String;@45a877
means this is an array ( [
) of class java.lang.String ( Ljava.lang.String;
). And @45a877
is the address where the String object is stored in memory.
I also met this problem when I've made ListView for android app:
Map<String, Object> m;
for(int i=0; i < dates.length; i++){
m = new HashMap<String, Object>();
m.put(ATTR_DATES, dates[i]);
m.put(ATTR_SQUATS, squats[i]);
m.put(ATTR_BP, benchpress[i]);
m.put(ATTR_ROW, row[i]);
data.add(m);
}
The problem was that I've forgotten to use the [i]
index inside the loop
Source: Stackoverflow.com