coderanch.com
Open in
urlscan Pro
204.144.184.130
Public Scan
URL:
https://coderanch.com/t/391737/java/Equivalent-eval-function-java
Submission: On June 21 via manual from DZ — Scanned from DE
Submission: On June 21 via manual from DZ — Scanned from DE
Form analysis
1 forms found in the DOMPOST https://coderanch.com/t/391737/java/Equivalent-eval-function-java
<form method="post" action="https://coderanch.com/t/391737/java/Equivalent-eval-function-java">
<input type="hidden" name="OWASP_CSRFTOKEN" value="EX7B-060W-4477-LUEN-GK8I-OEJN-VJF9-BZLK">
<input type="hidden" name="nonMobile" value="false">
<input type="submit" value="mobile view">
</form>
Text Content
Search... FAQs Subscribe Pie FAQs Recent topics Flagged topics Hot topics Best topics Search... Search within Beginning Java Search Coderanch Advance search Google search Register / Login Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP forum! * Post Reply Bookmark Topic Watch Topic * New Topic programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums this forum made possible by our volunteer staff, including ... Marshals: * Tim Cooke * Campbell Ritchie * Jeanne Boyarsky * Ron McLeod * Liutauras Vilda Sheriffs: * Rob Spoor * Junilu Lacar * paul wheaton Saloon Keepers: * Stephan van Hulst * Tim Moores * Tim Holloway * Carey Brown * Scott Selikoff Bartenders: * Piet Souris * Jj Roberts * fred rosenberger Forum: * Beginning Java EQUIVALENT OF EVAL() FUNCTION IN JAVA Pradyumna Hari Greenhorn Posts: 15 posted 20 years ago * * Number of slices to send: Optional 'thank-you' note: Send * * Hi all, Can any one tell me what is the equivalent of eval function ( this is a function in javascript ) in java. The requirement is to evaluate the value of an expression but the expression is itself a string. Example ClassA a = new ClassA(); String strExpression = "a.getName()" ; Now I want to print the value returned by a.getName(). Is there any function ftn such that System.out.println(ftn(strExpression)) would print the value returned by a.getName() Thanks [ June 04, 2002: Message edited by: Pradyumna Hari ] David O'Meara Rancher Posts: 13459 I like... posted 20 years ago * * Number of slices to send: Optional 'thank-you' note: Send * * You're looking for reflection. You can get a Class from an instance with ? 1 Class myClass = object.getClass(); then you can have a look at the class and do things like find and call methods etc. ? 1 2 3 4 5 Class[] args = new Class[0]; //get the zero-arg method called 'getname' java.lang.reflect.Method meth = myClass.getDeclaredMethod("getName", args); //call the method on our instance with no arguments myClass.invoke( object, new Object[0] ); or something like that... I didn't actually test the code, but it should get you started. Dave With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. reply reply Bookmark Topic Watch Topic * New Topic Boost this thread! Similar Threads * calling a method in jsp * Why to use eval function inside Javascript * Eval in java * Undefined on jQuery Ajax Request * calculate a string expression More... current ranch time (not your local time) is Jun 21, 2022 07:19:36 all times are in ranch time: GMT-6 in summer, GMT-7 in winter contact us | advertise | | Powered by JForum | copyright © 1998-2022 paul wheaton, missoula, MT