About 27,800 results
Open links in new tab
  1. Iterate Over the Characters of a String in Java - GeeksforGeeks

    Feb 28, 2022 · The simplest approach to solve this problem is to iterate a loop over the range [0, N – 1], where N denotes the length of the string, using the variable i and print the value of str …

  2. java - How can I print a certain string i times in a for loop?

    Jan 21, 2021 · to print * according to the value i contains each time it loops. It basically creates a new char array of size i and replaces all the nulls , i.e.('\0'), with * of that char array, and then it …

  3. Java Program to Iterate Over Characters in String

    Jun 6, 2021 · Method 1: Using for loops. The simplest or rather we can say naive approach to solve this problem is to iterate using a for loop by using the variable ‘ i’ till the length of the …

  4. java - Print a String 'X' Times (No Loop) - Stack Overflow

    You can make use of a char[] array of given length to build a String, then replace each character with *: String repeatedStar = new String(new char[4]).replace('\0', '*'); Well, that would use a …

  5. string - How to print value out loop java - Stack Overflow

    Oct 30, 2015 · Use String[] lineValue; instead of String lineValue because only last line is assigned to this variable and int k = 0; while ((line = reader.readLine()) != null) { …

  6. Java Program to Print Characters in a String - Tutorial Gateway

    Write a Java program to print characters in a string with an example. In the following example, we used for loop to iterate each and every character from start to end and print all the characters …

  7. Print a string N number of times in Java - CodeSpeedy

    Java Code for this is as follows. System.out.println("Printing the string" + N + "times in a single line."); Using the repeat () method. Java11 has a method to do this very easily. We can use …

  8. How to Iterate Over the String Characters in Java | Baeldung

    May 11, 2024 · In Java, there are several ways to iterate over the characters of a string, each with its own time and space complexity. The best method to use depends on the specific …

  9. How to print character multiple times in Java

    In Java, you can print a character multiple times using a loop or by simply repeating the character using a string concatenation approach. Here are two common ways to achieve this: Using a …

  10. How to Print a String in Java: A Simple Guide

    Mar 20, 2024 · In Java programming, when you need to display a string without automatically moving to the next line, you can employ the System.out.print () method. Unlike its counterpart …

  11. Some results have been removed
Refresh