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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:59:07+00:00 2026-05-21T21:59:07+00:00

I am developing with GWT and share a codebase with an Android developer. Some

  • 0

I am developing with GWT and share a codebase with an Android developer. Some functions we want to share take speciffic arguments like “Drawable” under Android and “Image” under GWT.

Is it possible to use a preprocessor variable as in C++:

#ifdef ANDROID
public void DrawImg(Drawable img);
#elif GWT
public void DrawImg(Image img);
#endif

The solution we are testing is a Generic like this:

interface DrawImgInterf<T extends Object> {
    public void DrawImg(T img);
}

However using a preproccesor variable seems better. Is there such a thing in Java?

  • 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-21T21:59:08+00:00Added an answer on May 21, 2026 at 9:59 pm

    No, there’s nothing like that in normal Java. You could run a preprocessor of course, but that will make it painful to develop the code. (Anything like an IDE which expects the code to be “normal” Java is going to get confused.)

    Have you considered using an interface instead, which abstracts out the common operations, and binds to the appropriate real type at execution time? That won’t always work (as adding a proxy breaks situations where object identity is important) but in some cases it can be helpful.

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

Sidebar

Related Questions

I am developing a GWT-Spring-Hibernate project and I want to use Spring Autowired annotation
I'm developing application with GWT 2 and would like to add float panel that
I already spent some time developing small projects with the GWT and I recently
When developing whether its Web or Desktop at which point should a developer switch
Greetings, I am developing GWT application where user can enter his details in Japanese.
I'm developing a GWT app running on the Google App Engine and wondering if
I'm currently in the process of developing a GWT 1.7.1 application that deals with
I am developing a web application in GWT 1.7.Now I am planning to move
I'm developing a web UI using GWT. While working only with the widgets I
I am developing an application in GWT which needs to call a native C++

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.