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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:44:01+00:00 2026-05-20T08:44:01+00:00

public static void main(String[] args) { int count, innerCount; for(count=0;count<=3;count++) { System.out.println(Count is +

  • 0
 public static void main(String[] args)  {

     int count, innerCount;
     for(count=0;count<=3;count++)
     {
         System.out.println("Count is" + count);
         for(innerCount=0; innerCount<count;innerCount++)
             System.out.print("Hi, innerCount is"+ innerCount);
     }
 }

}

Output:
Count is0

Count is1

Hi, innerCount is0Count is2

Hi, innerCount is0Hi, innerCount is1Count is3

Hi, innerCount is0Hi, innerCount is1Hi, innerCount is2

Can someone explain this for nested loop to me, please? When it is Count = 0 and 1 why is it not printing out any innerCounts? Also howcome innercounts are printing right next to Count? Thanks.

  • 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-20T08:44:02+00:00Added an answer on May 20, 2026 at 8:44 am

    When it is Count = 0 and 1 why is it not printing out any innerCounts?

    It is. When count is 0, the inner loop never executes its body, because the innerCount<count condition is never true (0<0 is false). When count is 1, the inner loop executes once, when innerCount is 0 (printing “Hi, innerCount is0”), because 0<1 is true. It doesn’t execute a second time because 1<1 is false.

    Also howcome innercounts are printing right next to Count? Thanks.

    Because you’re using System.out.print, which doesn’t append newlines. System.out.println appends newlines, if you want to use that.

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

Sidebar

Related Questions

public class Asterisk { public static void main(String[] args) { String output=""; int count=1,
public static void main(String[] args) { List<? extends Object> mylist = new ArrayList<Object>(); mylist.add(Java);
public class Test { public static void main(String[] args) { } } class Outer
public class doublePrecision { public static void main(String[] args) { double total = 0;
public class WrapperTest { public static void main(String[] args) { Integer i = 100;
The following code public class GenericsTest2 { public static void main(String[] args) throws Exception
Here is a quick test program: public static void main( String[] args ) {
If I make a JFrame like this public static void main(String[] args) { new
The method signature of a Java main method is: public static void main(String[] args)
The following code does not compile: public class GenericsTest { public static void main(String[]

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.