0

i'm a beginner trying to understand how to write a while loop code that write out numbers in order and how many depends on the loop. For example loop(3,6) results in 3456. This is my try this far

public static void loop(int start, int end){

int loop = 1;
while( loop <= start && end < runLoop ){
     System.out.print( start + end ) ;
loop = loop+1;
    
   }
}

1
  • What is runLoop ? Commented Nov 27, 2022 at 19:07

1 Answer 1

1

Just use start directly, until it reaches end:

public static void loop(int start, int end){
   while(start <= end){
      System.out.print(start);
      start++;    
   }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.