Headline

A program's ability to examine and modify programs in the same language

Illustration

Consider the following reflective Java code for printing "Hello, world!":

import java.lang.reflect.*;

/**
 * The main method constructs an object of this very class.
 * Then, an instance method with "Hello, world!" functionality is invoked.
 * Construction and method invocation is expressed in terms of reflection.
 */
public class Demo {

    // An instance method to print "Hello, world!"
    public void helloWorld() {
    System.out.println("Hello, world!");
    }

    // A main method to construct an instance and invoke helloWorld()
    public static void main(String[] args) {

	// Catch all (reflection-related?) exceptions
	try { 
	    Class<?> clss = Class.forName("Demo");
	    Constructor<?> cons = clss.getConstructor();
	    Object obj = cons.newInstance();
	    Method meth = clss.getMethod("helloWorld");
	    meth.invoke(obj);
	}
	catch (Exception e)
	{
	    System.out.println("java.lang.reflect may throw in many ways.");			
	}
    }
}

Metadata


There are no revisions for this page.

User contributions

    This user never has never made submissions.

    User edits

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.

    10 most similar pages:

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.