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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:36:05+00:00 2026-06-13T12:36:05+00:00

Can anybody explain the following codes to me? It is from the Android source

  • 0

Can anybody explain the following codes to me? It is from the Android source code.

The first line looks to me is to initialize an integer array, but what about those codes enclosed in braces? I mean are those codes syntax correct since the braces part
seems to be tangling?

    // high priority first
    mPriorityList = new int[mNetworksDefined];
    {
        int insertionPoint = mNetworksDefined-1;
        int currentLowest = 0;
        int nextLowest = 0;
        while (insertionPoint > -1) {
            for (NetworkAttributes na : mNetAttributes) {
                if (na == null) continue;
                if (na.mPriority < currentLowest) continue;
                if (na.mPriority > currentLowest) {
                    if (na.mPriority < nextLowest || nextLowest == 0) {
                        nextLowest = na.mPriority;
                    }
                    continue;
                }
                mPriorityList[insertionPoint--] = na.mType;
            }
            currentLowest = nextLowest;
            nextLowest = 0;
        }
    }
  • 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-13T12:36:06+00:00Added an answer on June 13, 2026 at 12:36 pm

    Yeah those code blocks are absolutely fine. They are viable syntax. Rather they are useful.

    What happens there is, the code is just shifted to an unnamed-block, to provide them a block scope. So, any variables defined inside that block won’t be visible outside.

    int[] a = new int[10];
    {
        int x = 10;
        a[0] = x;
        System.out.println(x);
    }
    
    System.out.println(x);  // Error. x not visible here.
    

    So, those braces just creates a local block scope, that’s it. Nothing more special in them. Though, you won’t feel the magic of those blocks in the above code.

    This way of coding is generally used to minimize the scope of your local variables, which is absolutely a good idea, specially when, the variables created inside that block won’t be used anywhere else.

    So, if used without those braces, those variables will just hang around, waiting for the garbage collector to free them up, at the same time, enjoying the trip towards the end of current scope, that might be a very long method.

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

Sidebar

Related Questions

Can anybody explain the working of following code...? interface myInterface{} public class Main {
can anybody explain why the following bash code involving compound operators is not behaving
Can anybody explain the following Perl code for me, please? I think its in
Was just wondering if anybody can look at the following code and explain to
Can anybody explain me the following code. I did not understand what % does.
I wanted to know if anybody can explain me the following piece of Javascript
Can anybody explain me why below code is working on private member variable? public
Can anybody explain to me how objects are stored and removed from heap memory
Can anybody explain what does JdClient is in this code: public JdClient client =
Link in this URL.. Please first two steps can anybody explain me? The System.Web.Mvc.dll

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.