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

  • Home
  • SEARCH
  • 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 8982685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:38:30+00:00 2026-06-15T20:38:30+00:00

What I am trying to achieve is as follows – I have a java

  • 0

What I am trying to achieve is as follows – I have a java class which calls a URL (passed to it), which returns JSON, which calls a call back from within the calling activity which processes the data.

This allows reusability of the aSyncTask code.

In some cases I needed to pass post data to the URL being called, so I created a new method with allows me to add data

HashMap<String, String> mData;        

public void AddDataToPost(HashMap<String, String> data) {
        mData = data;
     }

Then I pass this data with my httprequest.

My question is as follows.

I want to be able to pass any type of data in. For example a HashMap.. but i cannot do this because I have head to specify the bit when I initialized the var.

I could create an addHashMap method, but the same problem arises as the var is initialized as String, String.

How would I go about reusing code whilst allowing the passing of any data form?

THanks

  • 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-15T20:38:32+00:00Added an answer on June 15, 2026 at 8:38 pm

    You could define your class to use raw types, e.g.

    public MyClass<T>{
       ...
    }
    

    You could then do this:

    MyClass<Integer> intMyClass = new MyClass<>();
    
    MyClass<String>  strMyClass = new MyClass<>();
    

    Note though that you cannot pass primitives so you would have to box integers and so on.

    See this tutorial on Java Generics.

    http://docs.oracle.com/javase/tutorial/java/generics/types.html

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

Sidebar

Related Questions

im trying to achieve something but i dont really know how I have set
I am trying to achieve the following without LINQ: I have a list of
I am trying to achieve something roughly as follows: /* I assume that we
I'm pretty new to Javascript and have been trying to achieve some fading effects
I'm trying to achieve a goal which is adding some kind of wizard like
I am trying to write a piece of Java code which can deduce a
I am trying to achieve a scrolling effect using jQuery. I have a background
What I am trying to achieve is to have different layouts for each row.
I'm trying to achieve something like the following in C++: class MyVector; // 3
I'm trying to get to grips with class based views. I have urls.py as

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.