• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

225
Views
Java 'for loop' variables declared in the parameter list

How do I write a 'for' loop that starts counting from the given 'start' number? Without the first statement in the loop, the code will result in an error. Writing 'start = 0;' starts the counting from 0. Thanks in advance!

enter image description here

enter image description here

about 3 years ago · Santiago Trujillo
2 answers
Answer question

0

You can leave the initial statement blank and just put a semicolon.

for(; start <= end; start++)
about 3 years ago · Santiago Trujillo Report

0

Just do:

for(int i = start; i <= end; i++){
    end--;
    System.out.print(start);
}

Although in actuality if you want your code to work you have to do:

for(int i = start; i <= end; i++){
    System.out.print(start);
}
about 3 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error