Different types of Java method calls


import java.util.ArrayList;
import java.util.List;

public class MethodInvocation {
	public static void main(String [] args) {
		ArrayList mylist = new ArrayList();
		
		//invokevirtual:
		mylist.add(1);
		
		List listViaInterface = mylist;
		
		// invokeinterface
		listViaInterface.add(2);
		
		System.out.println(mylist);
		
		// invokestatic:
		char a = Character.toUpperCase('a');
		System.out.println(a);
	}
}

The kind not listed here is invokespecial for private methods.


This is an example from CSci 4651 course.

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.