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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:47:31+00:00 2026-05-26T23:47:31+00:00

So I declare a variable some where and initialize it. Now later on I

  • 0

So I declare a variable some where and initialize it. Now later on I need to use it to loop while its still positive so I need to decrement it. To me looping using a condition and a decrement calls for a for but for it we are missing the first part the initialization. But I don’t need to initialize anything. So how do I go about that in a nice way.

for (space = space; space > 0; space--)//my first way to do it but ide doesnt like it

Second way:

for (; space > 0; space--)//my friend recommended me this way but looks kind weird

Are there more ways for me to have a loop with only condition and increment/decrement?

P.S spell check doesn’t know that “decrement” is a word. I’m pretty sure it is…

  • 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-26T23:47:32+00:00Added an answer on May 26, 2026 at 11:47 pm

    another way is this one:

    Integer i = 10;
    while(--i>0) {
        System.out.println(i);
    }
    

    When i is 0 while condition is false… so.. it will print from 9 to 1 (9 items)

    Integer i = 10;
    while(i-->0) {
        System.out.println(i);
    }
    

    Will print from 9 to 0… (10 items);

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

Sidebar

Related Questions

I've seen some variable declare in VB.net in several way like: print(dim _Foo as
I noticed some people declare a private variable and then a public variable with
I have declared one variable in xslt, assigned some value to it but while
I declare a variable and some methods in the global nsobject class like @interface
For some reason, whenever I declare a directx variable as extern, I receive a
I'm creating a macro in C++ that declares a variable and assigns some value
I want to declare some global variables and global constants. Normally, I would put
With the following example stored procedure DECLARE Variable DOUBLE; DECLARE Variable2 DOUBLE; SELECT Something
I declare a variable for a 64 bit counter as : long long call_count;
If I declare a variable within a block (see below) is there a way

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.