Parameter and return value

Class name as the class name as a parameter and return value

1) the class name as a parameter
class name as a parameter to be actually ---- is an object class.
(2) method of the class name is returned as the value of
the class name as the return value returned is actually - objects of the class

Teacher {class 
	// class name as a form Student show method parameters 
	void show (Student S) { 
		s.study (); 
	} 
	
	// class name as the return value 
	Student getStudent () { 
		Student Student new new S = (); // Student class is instantiated 
		return S; 
	} 
} 

class Student { 
	String name; 
	int Age; 
	void Study () { 
		System.out.println ( "Study the I CAN"); 
	} 
} 

class Demo1 { 
	public static void main (String [ ] args) { 
		Teacher T = Teacher new new (); 
		Student Student new new S = (); 
		t.show (S); // CAN Study output the I 
		System.out.println (t.getStudent ()); // output object address value	 
	} 
}

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/lsswudi/p/11402346.html