0
Array
Please why am I getting an error after running this code?? public class program{ public static void main(String[] args){ String[ ] myClass = {"a", "b"}; System.out.println(myClass[ ]); } }
7 Antworten
+ 1
Manuel🔳
What's the error that you're getting? Mine is working fine
+ 1
Manuel🔳
You can also print an array along with its constituent elements using Arrays.toString(). Normally, when you print any reference data type, it outputs the address of the variable in Heap (this is not the case if the toString() method is overridden).
https://code.sololearn.com/cESkEaiKerJ7/?ref=app
+ 1
thanks bro actually that was what i was looking for and i thought it was impossible.. thanks
+ 1
Manuel🔳 You're welcome 😄
0
Don't use brackets to print the array.
0
still error and this time around 2 errors
0
i actually solved it, with value 1 inside the [ ].. i went back to the definition of an Array to get this right so it should rather be
public class program{
public static void main(String[] args){
String[ ] myClass = {"a", "b"};
System.out.println(myClass[1]);
}
}