Updated answer
This works:
public static void main(String[] chpt) {
int counter = Integer.parseInt(chpt[0]);
for (int i = 0; i <= counter; i++) {
System.out.println("over here " + square(i));
}
}
over here 0
over here 1
over here 4
over here 9
Array length
The magic 27 from your code is String length, not Array size:
chpt.toString().length() == 27
"[Ljava.lang.String;@5dcba031".length() == 27
The proper way is
System.out.println(chpt.size());
Printing arrays
With arrays it is:
public static void main(String[] args) {
System.out.println(java.util.Arrays.toString(args));
}
args is primitive type String[]
System.out.println(Arrays.toString(args));
and whent printed results with something like:
[Ljava.lang.String;@5dcba031
but after conversion to list"
System.out.println(Arrays.toString(args));
prints all elements nicely