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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:11:58+00:00 2026-06-03T09:11:58+00:00

According to my scientific Java experimentation, int x = 0; is equivalent to int

  • 0

According to my scientific Java experimentation, int x = 0; is equivalent to int x = 0;; which is equivalent to int x = 0;;;;;;;;;;;;;;;

  1. Why does Java allow for this? Does it have any practical application?
  2. Are each of these just empty statements? Do they actually take up any extra processing time during runtime? (I would assume they’re just optimized out?)
  3. Do other languages do this? I’m guessing it’s something inherited from C, like a lot of things in Java. Is this true?
  • 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-03T09:12:00+00:00Added an answer on June 3, 2026 at 9:12 am

    As Jake King writes, you can produce empty statements to do nothing in a loop:

    while (condition);
    

    but to make it obvious, you would write

    while (condition)
        ;
    

    or even better:

    while (condition)
    /** intentionally empty */
        ;
    

    or even better, as Michael Kjörling pointed out in the comment,

    while (condition)
    {
        /** intentionally empty */
    }
    

    More often, you see it in for-statements for endless loops:

    for (;;)
    

    or only one empty statement

    for (start;;) 
    for (;cond;) 
    for (;;end) 
    

    Another thing you can do, is, to write a program, once with one, and once with 2 semicolons:

    public class Empty
    {
        public static void main (String args[])
        {
            System.out.println ("Just semicolons");;
        }
    }
    

    Compile it, and run list the size of byte code (identic) and do an md5sum on the bytecode (identic).

    So in cases, where the semantics aren’t changed, it is clearly optimized away, at least for the 1.6-Oracle compiler I can say so.

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

Sidebar

Related Questions

According To reflector , ExpandoObject Does implemenet IDictionary<string, object> How ever I have this
According to this page here if you have proper application binary and .dSYM file
According to this discussion , the iphone agreement says that it doesn't allow loading
According to this article I know, that DateTimePicker control does not reflect CurrentUICulture So,
According to W3C standards, if you have a nillable element with a nil value,
According to MSDN , a hash function must have the following properties: If two
According to MSDN BOL (Books Online) description on SOME | ANY (Transact-SQL) , SOME
According to Steffen's post this is an efficient way to generate random BOOL s
According to Microsoft , you must sign your ClickOnce application. But it seems to
According to JavaScript Patterns book (p. 79), this should work: var ob = {

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.