About 29,200,000 results
Open links in new tab
  1. java - "return" statement with "for loop" - Stack Overflow

    Use a StringBuilder and do sb.append(" ").append(num[j]); inside the loop. Then return sb.toString(); after the loop. –

  2. Java return Keyword - GeeksforGeeks

    Jan 2, 2025 · return keyword in Java is a reserved keyword which is used to exit from a method, with or without a value. The usage of the return keyword can be categorized into two cases: …

  3. Java For Loop - W3Schools

    When you know exactly how many times you want to loop through a block of code, use the for loop instead of a while loop: Syntax for ( statement 1 ; statement 2 ; statement 3 ) { // code …

  4. Java For Loop - Baeldung

    Feb 16, 2025 · In this article, we’ll look at a core aspect of the Java language – executing a statement or a group of statements repeatedly using a for loop. 2. Simple for Loop. A for loop …

  5. Java For Loop (with Examples) - HowToDoInJava

    Nov 20, 2023 · Java for-loop statement is used to iterate over the arrays or collections using a counter variable that is incremented after each iteration. The for statement provides a compact …

  6. Is It Bad Practice to Use Return Inside a For Loop in Java?

    Using the return statement inside a for loop in Java is a common practice; however, certain misconceptions may lead developers to believe it can cause inefficiencies or difficulties in …

  7. java - How to use a for loop inside a return method? - Stack Overflow

    Dec 16, 2016 · It is possible prove that there is no way that the code after the loop (as written) can be reached. However, according to the JLS code reachability rules that the compiler is …

  8. The for Statement (The Java™ Tutorials > Learning the Java ... - Oracle

    Programmers often refer to it as the "for loop" because of the way in which it repeatedly loops until a particular condition is satisfied. The general form of the for statement can be expressed as …

  9. How to Break or return from Java Stream forEach in Java 8

    May 13, 2020 · In this tutorial, You'll learn how to use a break or return in Java 8 Streams when working with the forEach () method. Java 8 forEach () method takes consumer that will be …

  10. java - Looping over a list, checking a boolean and return value

    Aug 6, 2016 · Though for loop is enough, you can rewrite using Guava if you like lambdas: return Iterables.all(foos, new Predicate<Foo>() { public boolean apply(Foo foo) { return …

  11. Some results have been removed
Refresh