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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:00:36+00:00 2026-05-15T02:00:36+00:00

hi i have question i know that this question is somehow nonsense but let

  • 0

hi i have question i know that this question is somehow nonsense but let see i have code to merge two sorted array in a one sorted array here is code in java

public class Merge {

    public static void main(String[]args){

       int a[]=new int[]{7,14,23,30,35,40};
       int b[]=new int[]{5,8,9,11,50,67,81};
       int c[]=new int[a.length+b.length];
       int al=0;
       int bl=0;
       int cl=0;

       while (al<a.length && bl<b.length)              
          if (a[al]<b[bl])
              c[cl++]=a[al++];   
          else  
              c[cl++]=b[bl++];


       while (al<a.length)
          c[cl++]=a[al++];

       while (bl<b.length)
          c[cl++]=b[bl++];

       for (int j=0;j<c.length;j++){
          System.out.println(c[j]);
       }


    }
}

question is why does not work if we write here {} brackets

while (al<a.length && bl<b.length){
}

?

  • 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-15T02:00:37+00:00Added an answer on May 15, 2026 at 2:00 am

    If my guess is correct, your question is……why the following code doesn’t work?

    while (al<a.length && bl<b.length)
    { //<-- bracket here
    
        if (a[al]<b[bl])
          c[cl++]=a[al++];
    
    
         else  
         c[cl++]=b[bl++];
    
    
        while (al<a.length)
          c[cl++]=a[al++];
    
        while (bl<b.length)
         c[cl++]=b[bl++];
    } //<--- Bracket here
    

    If that is the case,

    while (al<a.length && bl<b.length)
    

    would fail after first iteration.

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

Sidebar

Related Questions

I know that this question must have been asked and answered a million times,
I know that this is a repeated question. I have found very similar questions
I know this question might have already been discussed a thousands of times but
I know variants of this question have been asked before (even by me), but
I know that there is already a question (actually some more) about this, but
I have a question about relational databases. I know that when using this I
I know that this question is perfectly answered in FOSUserBundle documentation, but yet I
I have a quick question here. I know that the cakePHP find('first') function returns
hello I have a small question in objective-C memory management. I know that if
I know that similar questions have been asked before, but I am very much

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.