본문 바로가기
JAVA

JAVA - 멤버변수에 사용하는 this

by leo104 2023. 1. 19.
728x90
멤버 변수

private String name;
private String tel;
private String address;



함수 
void setData(String name, String tel, String address){
		this.name = name;
		this.tel = tel;
		this.address = address;
		System.out.println(this.name);
		System.out.println(this.tel);
		System.out.println(address);
		System.out.println("  ");

이런 식으로 멤버 변수와 파라미터에 들어가는 변수의 이름이 같을때 헷갈리기 때문에

멤버 변수앞에는 this.을 붙여 멤버변수인것을 표시해준다

728x90

'JAVA' 카테고리의 다른 글

JAVA - 접근제어자의 설명  (0) 2023.01.19
JAVA - getter / setter 함수 사용법  (0) 2023.01.19
JAVA - 생성자 메소드 오버로딩 하기  (0) 2023.01.19
JAVA - 생성자의 의미  (0) 2023.01.19
JAVA - 메소드 오버로딩  (0) 2023.01.19