Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 787487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:12:35+00:00 2026-05-14T21:12:35+00:00

basically I need to get a constant for a class however I have no

  • 0

basically I need to get a constant for a class however I have no instance of the object but only its class.
In PHP I would do constant(XYZ);
Is there a similar way of retrieving a constant in JAVA?

I need it to facilitate a dynamic getMethod call

Class parameterType = Class.forName(class_name);
object.setProperty(field name, field value, parameterType);

the set property method would then get the correct method and set the specified property, however I cant get a method which has int as parameter type without using Interger.TYPE

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T21:12:36+00:00Added an answer on May 14, 2026 at 9:12 pm

    I am not sure what you want to get out. But it shouldn’t be too difficult to show you an example.

    Lets say you have a Class Foo with property bar.

    Class Foo {
        private final String bar = "test";
        public String getBar() {return bar;}
    }
    

    Now to get this through reflection you would:

    Class fooClass = Foo.class;
    Object fooObj = fooClass.newInstance();
    Method fooMethod = fooClass.getMethod("getBar");
    String bar = (String) fooMethod.invoke(fooObj);
    

    Now you will get value of method getBar() in bar variable

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an html-like xml, basically it is html. I need to get the
I have a web application. On the client side I basically need to get
Basically I need to get a list of CampaignTitles that have more than 2
I basically need to get user input: gets.chomp(input?) And then to convert the given
Basically I need to get older version of a file in the repository without
I need a regular expression to basically get the first part of a string,
I basically need a custom function to be used only when, for example, the
I need to get the current date, but ignoring minutes and seconds, and then
Basically, I have a class defined in my website which contains a bunch of
Basically, I want to have an app with only one view that has an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.