07 October 2012

creating object from string in java

import java.io.*;
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;


   
   

class test{
   
   
    static void display()
    {
        System.out.println("this is display");
        }
   
    public static void main(String args[]) throws Exception
    {
       
    String s="test";
   
    ((test)Class.forName(s).newInstance()).display();
       
    }
       
    }   




Delicious add to del.icio.us saved by 0 users

No comments:

Post a Comment