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 8495983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:43:30+00:00 2026-06-10T23:43:30+00:00

if i have a type stored in a variable (def ta java.util.Vector) how can

  • 0

if i have a type stored in a variable

(def ta java.util.Vector)

how can I initialise a new Vector type with the symbol stored in a?

eg.
(initialize ta params) => #Vector <params>

  • 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-06-10T23:43:32+00:00Added an answer on June 10, 2026 at 11:43 pm

    Well your ta is an instance of java.lang.Class, so you can just use the newInstance method directly:

    (.newInstance ta)
    => #<Vector []>
    

    If you want to use parameters to the constructor, you can go via the getConstructor method with something like:

    (defn build-constructor [klass & types]
      "Construct a new class instance dynamically at runtime"
      (let [constructor (.getConstructor klass (into-array java.lang.Class types))]
        (fn [& args]
          (.newInstance constructor (object-array args)))))
    
    ((build-constructor ta java.util.Collection) [1 2 3 4])
    => #<Vector [1, 2, 3, 4]>
    

    Although this can be a bit more fiddly as you need to exactly match the parameter types in order to obtain the right constructor….

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

Sidebar

Related Questions

I have a System.Type stored in a variable. I wish to Change an object's
I have stored a variable in database(sqlite) with datetime data type. Now I want
I have an image that is currently stored in variable of type File.. File
How can I read (and put into new variable) data stored at specific memory
I have the number 2.50 stored in a variable called $price which I can
I have got the XML below, which is stored in string type variable, and
I have a list of type stored procedure which have an ID and a
I have a char type array[100] with 100 bytes stored in it. I want
I have a stored procedure which accepts a User defined table type called SeasonTable
I have some text stored in the body field of a custom content type

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.