[JAVA] Glossary: Member Variables / Local Variables

What is a member variable?

Example

Conceptual image

Object: Our rabbit ... thing Member variables: cute, scared, clumsy ... what is it like? Method: Sleep, eat, bounce, run ... how can you move?

Code image


public class Rabbit{

	Int age;		//Store member variable age
	String personality;	//Store member variable personality


	void setAge(int newAge){
		age = newAge;
	}

	Int getAge(){
		return age;
	}
}

What are local variables?

Example

Public class Variable{
	Public static void main(String[] args){
		String rabbit; 
		//Local variables that can only be referenced within the main method
	} 
}

I will add it when I come up with it.

Recommended Posts

Glossary: Member Variables / Local Variables
Java local variables are thread safe
Item 57 Minimize the scope of local variables
Item 57: Minimize the scope of local variables