{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

001 - Driver.java import java.io import java.uti1 import...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Driver.java import java.io.*; import java.uti1.*; import java.1ang.ref]ect.Constructor; import java.1ang.ref1ect.Method; ciass Driver { €ub1ic void print() try { System.out.printin(”Enter the ciass ti1e name with out extension"); Strin c1a55name = (new BufferedReaderCnew InputStreamReader(System.in)) .readLineC); C1a55 C15 = C1ass.forName(c1a55name); Object obj = cis.neWInstance(): Constructor consf] = c1s.getDec1aredconstructOFSC); /*reading a11 constructors*/ Method methods : cis.getDec1aredMethods(); /*reading 311 methods*/ System.out.print]nC"********f****Constrnctors***********f*“); for(1nt i = 0; 1 < cons.1ength; 1++) { System.out.print(cons[i1.getName()+"(”); _ Class c1asses = cons[i}.getParameterType5();/*reqd1ng parameters' type of a construct0r*/ int 1 — 0:, Eor(] = 0; j < c1asses.1ength — l; j++) System.dut.print(c1asses[j].getName()+ . ); if(c1asses.1ength !: 0) System.out.print(c1asses[j].getName()); System.0ut.print1n(”)”); } System_ out _ pr-i mt] nC"*kfi'k'kf:**=::7‘:**Methods‘i-t'k'k‘k'kfri'k***W**#****") ’ forC1nt i = 0; i < methods.1ength; i++) String name = methods[i].getName(): System.out.print(name+"("); C1ass c1asses = methods[i].getParameterTypesC); {*reading parameters' type of a method*/ int j = 0;;_ _ forCJ = 0; 3 < c1asses.1ength — l; j++) System.out.print(c1asses[j].getName()+”,”); if(c1asses.1ength l: 0) System.out.printhiasses[j].getNameCD); /’ system.out.printcn)..4_.. n); if(c1asses.1ength =: 0) /*no parameters for that method*/ { methodsEi].invoke(obj); ‘—-—— eise /*Method with parameters*/ { Page 1 ...
View Full Document

{[ snackBarMessage ]}