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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:15:41+00:00 2026-06-17T23:15:41+00:00

I need to reverse an array for example move what ever is in spot

  • 0

I need to reverse an array for example move what ever is in spot 5 to 0, 4 to1, 3 to 2.

            int size, length;

    System.out.print("how big of a list do you have: ");
    size=reader.nextInt();

    length=size-1;

    int [] array = new int [size];

    for (int count=0; count < array.length; count ++){
        System.out.println("enter a number: ");
        array [count] = reader.nextInt();
    }
    for (int count=length; count > 0; count --)
    array [(length-count)];
}

}

I am doing this in eclipse and I keep getting an error in the last line saying that I am not using an operator/expression : array [(length-count)]; but I dont know why the minus sign is not working? or if my program will work in general it did not get past the build part.

  • 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-17T23:15:42+00:00Added an answer on June 17, 2026 at 11:15 pm
    int temp = 0;
    for (int i = 0; i < array.length / 2; i++)
    {
        int temp = array[i];
        array[i] = array[array.length - i--];
        array[array.length - i--] = temp;
    }
    

    temp is used so that numbers don’t overwrite each other. Think of it like getting food from a fridge. The milk is behind the water, and you want some milk. In order to get the milk, you take the water and put it in your hand (temp would be the hand). You then put the milk where the water was and the water where the milk was. Without the “hand”, you would have lost your water (fallen on the floor, or in the case of temp, lost in memory) and only be left with milk.

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

Sidebar

Related Questions

i need to write a function void reverse(void *base, int nel, int width) {
I need to recursively reverse a HUGE array that has many levels of sub
I think I need a reverse version of strtok, like: char* p = rstrtok(str,
I need to make a reverse proxy back to a tomcat server running a
Using C#, I need to do a reverse look up my resource file. I
I have nginx acting as a reverse proxy to apache. I now need to
I have nginx setup, acting as a reverse proxy to apache. However, I need
I need to write an integer to a byte array such that leading zeros
Regarding passing arrays to functions and then manipulating the array contents (Array.Reverse) and then
I hardly use reverse_each method, instead I call upon reverse.each when I need to

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.