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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:55:24+00:00 2026-06-10T08:55:24+00:00

I want to make an If statement: if(x == y+n) { } n =

  • 0

I want to make an If statement:

if(x == y+n)

{ }

n = [-20...20]

where n can be any integer value from -20 to 20.

How to do this in java?

In android I am trying to “synchronize” the ontouch listener to drawView. So I mean an image randomly appears I want to perform a certain action when the image appears….So the “touch” on the screen is pretty precise…

----DrawView Class---

setX(rand.nextInt(width-20));
setY(rand.nextInt(height-20));
canvas.drawBitmap(b, getX(), getY(), paint);


public boolean onTouch(View arg0, MotionEvent event) {
if (event.getX() == DrawView.getX()|| event.getY() == DrawView.getY())
{
Certian action...
} 
}

so how can I include, DrawView.getX()+[-20…20] and DrawView.getY()+[-20…20]?

  • 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-10T08:55:26+00:00Added an answer on June 10, 2026 at 8:55 am

    If I understand your question correctly, you might mean this:

    int n = x - y;
    if (n >= -20 && n <= 20) {
        // etc...
    }
    

    For your specific range, you can simplify this expression by using Math.abs:

    if (Math.abs(x - y) <= 20) {
        // etc ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may sound complicated but I can answer any questions. What I am trying
Basically I want to make an if statement that only shows the date of
I want to make many inserts in a single SQL statement, pretty much like
I want make a bash script which returns the position of an element from
I want make interactive application where user launches it and can do various task
I am new android app developer i want make app for tablets and phone
I'm trying to make sure that I don't leave any loose ends open in
Here I want to make some modificatins for my setting. I want response from
I am trying to execute the following statement: DELETE a FROM db.table1 a INNER
I'm trying to make a very simple toggle switch and I want to store

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.