컴퓨터/Java

toString()

수제녹차 2019. 11. 21. 09:44
728x90
반응형

- When we print out Objects, we often see a String that is not very helpful in determining what the Object represents. 주소를 보여준다든지...

- We can return a String that will print when we print the object.

public String toString() {

}

 

- import java.util.Arrays;

array를 print하면 memory address가 나온다.

therefore we need a toString() method that is provided by the Arrays package in Java.

Arrays.toString(array객체) : can see the contents of the array printed out

 

 

출처 : codecademy

반응형