Printing array-content in Java without a loop #javaprogramming #java #shorts



Printing array-content in Java without a loop #javaprogramming #java #shorts

Printing array-content in Java without a loop  #javaprogramming  #java #shorts

Is it possible to print the content of an Array without using a loop?

Normally, the use of a loop to print each element of an array works just fine! Sometimes, new programmers try to print an array directly by printing the array variable, which does not really print the content but instead prints a reference representation of the array. So, directly printing the array variable does not work.

An alternative to print the content of a one-dimensional array is using the Arrays class of java.util package. Just Use the Arrays.tostring method to convert the content of the array to a String, and then print the converted String a print-line statement.

The video shows the detailed code.

Dr. Shahriar Hossain and Dr. Monika Akbar
https://computing4all.com